feat:媒体搜索聚合开关
This commit is contained in:
@ -43,6 +43,8 @@ class Settings(BaseSettings):
|
||||
WALLPAPER: str = "tmdb"
|
||||
# 网络代理 IP:PORT
|
||||
PROXY_HOST: Optional[str] = None
|
||||
# 媒体搜索来源 themoviedb/douban/bangumi,多个用,分隔
|
||||
SEARCH_SOURCE: str = "themoviedb,douban,bangumi"
|
||||
# 媒体识别来源 themoviedb/douban
|
||||
RECOGNIZE_SOURCE: str = "themoviedb"
|
||||
# 刮削来源 themoviedb/douban
|
||||
|
@ -1,7 +1,9 @@
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
from app import schemas
|
||||
from app.core.config import settings
|
||||
from app.core.context import MediaInfo
|
||||
from app.core.meta import MetaBase
|
||||
from app.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules.bangumi.bangumi import BangumiApi
|
||||
@ -54,6 +56,21 @@ class BangumiModule(_ModuleBase):
|
||||
|
||||
return None
|
||||
|
||||
def search_medias(self, meta: MetaBase) -> Optional[List[MediaInfo]]:
|
||||
"""
|
||||
搜索媒体信息
|
||||
:param meta: 识别的元数据
|
||||
:reutrn: 媒体信息
|
||||
"""
|
||||
if settings.SEARCH_SOURCE and "bangumi" not in settings.SEARCH_SOURCE:
|
||||
return None
|
||||
if not meta.name:
|
||||
return []
|
||||
infos = self.bangumiapi.search(meta.name)
|
||||
if infos:
|
||||
return [MediaInfo(bangumi_info=info) for info in infos]
|
||||
return []
|
||||
|
||||
def bangumi_info(self, bangumiid: int) -> Optional[dict]:
|
||||
"""
|
||||
获取Bangumi信息
|
||||
|
@ -12,6 +12,7 @@ class BangumiApi(object):
|
||||
"""
|
||||
|
||||
_urls = {
|
||||
"search": "search/subjects/%s?type=2",
|
||||
"calendar": "calendar",
|
||||
"detail": "v0/subjects/%s",
|
||||
"credits": "v0/subjects/%s/persons",
|
||||
@ -40,6 +41,15 @@ class BangumiApi(object):
|
||||
print(e)
|
||||
return None
|
||||
|
||||
def search(self, name):
|
||||
"""
|
||||
搜索媒体信息
|
||||
"""
|
||||
result = self.__invoke("search/subject/%s" % name)
|
||||
if result:
|
||||
return result.get("list")
|
||||
return []
|
||||
|
||||
def calendar(self):
|
||||
"""
|
||||
获取每日放送,返回items
|
||||
|
@ -544,6 +544,8 @@ class DoubanModule(_ModuleBase):
|
||||
:param meta: 识别的元数据
|
||||
:reutrn: 媒体信息
|
||||
"""
|
||||
if settings.SEARCH_SOURCE and "douban" not in settings.SEARCH_SOURCE:
|
||||
return None
|
||||
if not meta.name:
|
||||
return []
|
||||
result = self.doubanapi.search(meta.name)
|
||||
|
@ -227,6 +227,8 @@ class TheMovieDbModule(_ModuleBase):
|
||||
:param meta: 识别的元数据
|
||||
:reutrn: 媒体信息列表
|
||||
"""
|
||||
if settings.SEARCH_SOURCE and "themoviedb" not in settings.SEARCH_SOURCE:
|
||||
return None
|
||||
if not meta.name:
|
||||
return []
|
||||
if meta.type == MediaType.UNKNOWN and not meta.year:
|
||||
|
Reference in New Issue
Block a user