support additional douban url format
This commit is contained in:
parent
6c2e7ce00a
commit
a12713cccb
8 changed files with 69 additions and 46 deletions
|
@ -1,4 +1,5 @@
|
|||
from django.test import TestCase
|
||||
|
||||
from catalog.common import *
|
||||
from catalog.common.sites import crawl_related_resources_task
|
||||
|
||||
|
@ -10,6 +11,9 @@ class DoubanDramaTestCase(TestCase):
|
|||
def test_parse(self):
|
||||
t_id = "24849279"
|
||||
t_url = "https://www.douban.com/location/drama/24849279/"
|
||||
t_url2 = (
|
||||
"https://www.douban.com/doubanapp/dispatch?uri=/drama/24849279/&dt_dapp=1"
|
||||
)
|
||||
p1 = SiteManager.get_site_cls_by_id_type(IdType.DoubanDrama)
|
||||
self.assertIsNotNone(p1)
|
||||
p1 = SiteManager.get_site_by_url(t_url)
|
||||
|
@ -17,6 +21,7 @@ class DoubanDramaTestCase(TestCase):
|
|||
self.assertEqual(p1.validate_url(t_url), True)
|
||||
self.assertEqual(p1.id_to_url(t_id), t_url)
|
||||
self.assertEqual(p1.url_to_id(t_url), t_id)
|
||||
self.assertEqual(p1.url_to_id(t_url2), t_id)
|
||||
|
||||
@use_local_response
|
||||
def test_scrape(self):
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from catalog.common import *
|
||||
from .douban import *
|
||||
from catalog.book.models import *
|
||||
from catalog.book.utils import *
|
||||
import logging
|
||||
|
||||
from catalog.book.models import *
|
||||
from catalog.book.utils import *
|
||||
from catalog.common import *
|
||||
|
||||
from .douban import *
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -15,6 +16,7 @@ class DoubanBook(AbstractSite):
|
|||
URL_PATTERNS = [
|
||||
r"\w+://book\.douban\.com/subject/(\d+)/{0,1}",
|
||||
r"\w+://m.douban.com/book/subject/(\d+)/{0,1}",
|
||||
r"\w+://www.douban.com/doubanapp/dispatch\?uri=/book/(\d+)/",
|
||||
]
|
||||
WIKI_PROPERTY_ID = "?"
|
||||
DEFAULT_MODEL = Edition
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import logging
|
||||
import re
|
||||
|
||||
from django.core.cache import cache
|
||||
from lxml import html
|
||||
|
||||
from catalog.common import *
|
||||
from catalog.models import *
|
||||
|
||||
from .douban import DoubanDownloader
|
||||
import logging
|
||||
from lxml import html
|
||||
from django.core.cache import cache
|
||||
import re
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -112,7 +115,10 @@ class DoubanDramaVersion(AbstractSite):
|
|||
class DoubanDrama(AbstractSite):
|
||||
SITE_NAME = SiteName.Douban
|
||||
ID_TYPE = IdType.DoubanDrama
|
||||
URL_PATTERNS = [r"\w+://www.douban.com/location/drama/(\d+)/[^#]*$"]
|
||||
URL_PATTERNS = [
|
||||
r"\w+://www.douban.com/location/drama/(\d+)/[^#]*$",
|
||||
r"\w+://www.douban.com/doubanapp/dispatch\?uri=/drama/(\d+)/",
|
||||
]
|
||||
WIKI_PROPERTY_ID = "P6443"
|
||||
DEFAULT_MODEL = Performance
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from catalog.common import *
|
||||
from catalog.models import *
|
||||
from .douban import DoubanDownloader
|
||||
import dateparser
|
||||
import logging
|
||||
|
||||
import dateparser
|
||||
|
||||
from catalog.common import *
|
||||
from catalog.models import *
|
||||
|
||||
from .douban import DoubanDownloader
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -15,6 +17,7 @@ class DoubanGame(AbstractSite):
|
|||
URL_PATTERNS = [
|
||||
r"\w+://www\.douban\.com/game/(\d+)/{0,1}",
|
||||
r"\w+://m.douban.com/game/subject/(\d+)/{0,1}",
|
||||
r"\w+://www.douban.com/doubanapp/dispatch\?uri=/game/(\d+)/",
|
||||
]
|
||||
WIKI_PROPERTY_ID = ""
|
||||
DEFAULT_MODEL = Game
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from catalog.common import *
|
||||
from .douban import *
|
||||
from catalog.movie.models import *
|
||||
from catalog.tv.models import *
|
||||
import logging
|
||||
import json
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from .tmdb import TMDB_TV, TMDB_TVSeason, search_tmdb_by_imdb_id, query_tmdb_tv_episode
|
||||
|
||||
from .douban import *
|
||||
from .tmdb import TMDB_TV, TMDB_TVSeason, query_tmdb_tv_episode, search_tmdb_by_imdb_id
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -18,6 +20,7 @@ class DoubanMovie(AbstractSite):
|
|||
URL_PATTERNS = [
|
||||
r"\w+://movie\.douban\.com/subject/(\d+)/{0,1}",
|
||||
r"\w+://m.douban.com/movie/subject/(\d+)/{0,1}",
|
||||
r"\w+://www.douban.com/doubanapp/dispatch\?uri=/movie/(\d+)/",
|
||||
]
|
||||
WIKI_PROPERTY_ID = "?"
|
||||
# no DEFAULT_MODEL as it may be either TV Season and Movie
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import logging
|
||||
|
||||
import dateparser
|
||||
|
||||
from catalog.common import *
|
||||
from catalog.models import *
|
||||
from catalog.music.utils import upc_to_gtin_13
|
||||
from .douban import DoubanDownloader
|
||||
import dateparser
|
||||
import logging
|
||||
|
||||
from .douban import DoubanDownloader
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -16,6 +18,7 @@ class DoubanMusic(AbstractSite):
|
|||
URL_PATTERNS = [
|
||||
r"\w+://music\.douban\.com/subject/(\d+)/{0,1}",
|
||||
r"\w+://m.douban.com/music/subject/(\d+)/{0,1}",
|
||||
r"\w+://www.douban.com/doubanapp/dispatch\?uri=/music/(\d+)/",
|
||||
]
|
||||
WIKI_PROPERTY_ID = ""
|
||||
DEFAULT_MODEL = Album
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<i class="fa-solid fa-globe"></i> 登录{{ site_name }}的最佳方式通过联邦宇宙(Fediverse,有时也被称为长毛象,一种分布式社交网络)实例账号,如果你还没有注册过,可先<a href="https://joinmastodon.org/zh/servers" target="_blank">选择实例并注册</a>。
|
||||
</p>
|
||||
<p>
|
||||
<i class="fa-regular fa-envelope"></i> 如果还没准备好注册联邦宇宙也没问题,你可以在登录页面选择电子邮件注册,未来再连接到联邦宇宙。
|
||||
<i class="fa-solid fa-envelope"></i> 如果还没准备好注册联邦宇宙也没问题,你可以在登录页面选择电子邮件注册,未来再连接到联邦宇宙。
|
||||
</p>
|
||||
<p>
|
||||
<i class="fa-solid fa-circle-question"></i> 如果有任何问题或建议,欢迎通过<a href="https://mastodon.social/@neodb">联邦宇宙</a>或<a href="https://discord.gg/uprvcH8gqD">Discord</a>和我们联系。
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
from django.db import models
|
||||
import re
|
||||
import uuid
|
||||
from functools import cached_property
|
||||
|
||||
import django.dispatch
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
|
||||
from django.db import connection, models
|
||||
from django.db.models import Avg, Count, Q
|
||||
from django.utils import timezone
|
||||
from django.utils.baseconv import base62
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from markdownx.models import MarkdownxField
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
from catalog.collection.models import Collection as CatalogCollection
|
||||
from catalog.common import jsondata
|
||||
from catalog.common.models import Item, ItemCategory
|
||||
from catalog.common.utils import DEFAULT_ITEM_COVER, piece_cover_path
|
||||
from catalog.models import *
|
||||
from mastodon.api import share_review
|
||||
from users.models import User
|
||||
from catalog.common.models import Item, ItemCategory
|
||||
|
||||
from .mixins import UserOwnedObjectMixin
|
||||
from catalog.collection.models import Collection as CatalogCollection
|
||||
from markdownx.models import MarkdownxField
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.validators import RegexValidator
|
||||
from functools import cached_property
|
||||
from django.db.models import Count, Avg
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
import django.dispatch
|
||||
import uuid
|
||||
import re
|
||||
from catalog.common.utils import DEFAULT_ITEM_COVER, piece_cover_path
|
||||
from django.utils.baseconv import base62
|
||||
from django.db.models import Q
|
||||
from catalog.models import *
|
||||
from .renderers import render_md, render_text
|
||||
from catalog.common import jsondata
|
||||
from django.db import connection
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -703,7 +703,7 @@ class ShelfManager:
|
|||
for qt in ShelfType:
|
||||
self.shelf_list[qt] = Shelf.objects.create(owner=self.owner, shelf_type=qt)
|
||||
|
||||
def locate_item(self, item) -> ShelfMember:
|
||||
def locate_item(self, item) -> ShelfMember | None:
|
||||
return ShelfMember.objects.filter(item=item, owner=self.owner).first()
|
||||
|
||||
def move_item(self, item, shelf_type, visibility=0, metadata=None):
|
||||
|
@ -1020,7 +1020,8 @@ class TagManager:
|
|||
tag.append_item(item, visibility=default_visibility)
|
||||
for title in current_titles - titles:
|
||||
tag = Tag.objects.filter(owner=user, title=title).first()
|
||||
tag.remove_item(item)
|
||||
if tag:
|
||||
tag.remove_item(item)
|
||||
|
||||
@staticmethod
|
||||
def get_item_tags_by_user(item, user):
|
||||
|
|
Loading…
Add table
Reference in a new issue