mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-05-11 18:10:15 +08:00
feat:单独设置刮削图片语言 #4245
This commit is contained in:
@@ -103,6 +103,8 @@ class ConfigModel(BaseModel):
|
||||
TMDB_API_DOMAIN: str = "api.themoviedb.org"
|
||||
# TMDB元数据语言
|
||||
TMDB_LOCALE: str = "zh"
|
||||
# TMDB海报图片语言
|
||||
TMDB_SCRAP_IMAGE_LOCALE: str = "zh"
|
||||
# TMDB API Key
|
||||
TMDB_API_KEY: str = "db55323b8d3e4154498498a75642b381"
|
||||
# TVDB API Key
|
||||
|
||||
@@ -37,7 +37,7 @@ class TheMovieDbModule(_ModuleBase):
|
||||
self.cache = TmdbCache()
|
||||
self.tmdb = TmdbApi()
|
||||
self.category = CategoryHelper()
|
||||
self.scraper = TmdbScraper(self.tmdb)
|
||||
self.scraper = TmdbScraper()
|
||||
|
||||
@staticmethod
|
||||
def get_name() -> str:
|
||||
|
||||
@@ -7,15 +7,31 @@ from app.core.context import MediaInfo
|
||||
from app.core.meta import MetaBase
|
||||
from app.schemas.types import MediaType
|
||||
from app.utils.dom import DomUtils
|
||||
from app.modules.themoviedb.tmdbapi import TmdbApi
|
||||
|
||||
|
||||
class TmdbScraper:
|
||||
tmdb = None
|
||||
_force_nfo = False
|
||||
_force_img = False
|
||||
_meta_tmdb = None
|
||||
_img_tmdb = None
|
||||
|
||||
@property
|
||||
def meta_tmdb(self):
|
||||
"""
|
||||
获取元数据TMDB Api
|
||||
"""
|
||||
if not self._meta_tmdb:
|
||||
self._meta_tmdb = TmdbApi(language=settings.TMDB_LOCALE)
|
||||
return self._meta_tmdb
|
||||
|
||||
@property
|
||||
def img_tmdb(self):
|
||||
"""
|
||||
获取图片TMDB Api
|
||||
"""
|
||||
if not self._img_tmdb:
|
||||
self._img_tmdb = TmdbApi(language=settings.TMDB_SCRAP_IMAGE_LOCALE)
|
||||
return self._img_tmdb
|
||||
|
||||
def __init__(self, tmdb):
|
||||
self.tmdb = tmdb
|
||||
|
||||
def get_metadata_nfo(self, meta: MetaBase, mediainfo: MediaInfo,
|
||||
season: Optional[int] = None, episode: Optional[int] = None) -> Optional[str]:
|
||||
@@ -33,9 +49,9 @@ class TmdbScraper:
|
||||
if season is not None:
|
||||
# 查询季信息
|
||||
if mediainfo.episode_group:
|
||||
seasoninfo = self.tmdb.get_tv_group_detail(mediainfo.episode_group, season=season)
|
||||
seasoninfo = self.meta_tmdb.get_tv_group_detail(mediainfo.episode_group, season=season)
|
||||
else:
|
||||
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, season=season)
|
||||
seasoninfo = self.meta_tmdb.get_tv_season_detail(mediainfo.tmdb_id, season=season)
|
||||
if episode:
|
||||
# 集元数据文件
|
||||
episodeinfo = self.__get_episode_detail(seasoninfo, meta.begin_episode)
|
||||
@@ -65,9 +81,9 @@ class TmdbScraper:
|
||||
if episode:
|
||||
# 集的图片
|
||||
if mediainfo.episode_group:
|
||||
seasoninfo = self.tmdb.get_tv_group_detail(mediainfo.episode_group, season)
|
||||
seasoninfo = self.img_tmdb.get_tv_group_detail(mediainfo.episode_group, season)
|
||||
else:
|
||||
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, season)
|
||||
seasoninfo = self.img_tmdb.get_tv_season_detail(mediainfo.tmdb_id, season)
|
||||
if seasoninfo:
|
||||
episodeinfo = self.__get_episode_detail(seasoninfo, episode)
|
||||
if episodeinfo and episodeinfo.get("still_path"):
|
||||
@@ -77,7 +93,7 @@ class TmdbScraper:
|
||||
images[still_name] = still_url
|
||||
else:
|
||||
# 季的图片
|
||||
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, season)
|
||||
seasoninfo = self.img_tmdb.get_tv_season_detail(mediainfo.tmdb_id, season)
|
||||
if seasoninfo:
|
||||
# TMDB季poster图片
|
||||
poster_name, poster_url = self.get_season_poster(seasoninfo, season)
|
||||
|
||||
@@ -23,7 +23,7 @@ class TmdbApi:
|
||||
TMDB识别匹配
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, language: Optional[str] = None):
|
||||
# TMDB主体
|
||||
self.tmdb = TMDb()
|
||||
# 域名
|
||||
@@ -33,7 +33,7 @@ class TmdbApi:
|
||||
# APIKEY
|
||||
self.tmdb.api_key = settings.TMDB_API_KEY
|
||||
# 语种
|
||||
self.tmdb.language = settings.TMDB_LOCALE
|
||||
self.tmdb.language = language or settings.TMDB_LOCALE
|
||||
# 代理
|
||||
self.tmdb.proxies = settings.PROXY
|
||||
# 调试模式
|
||||
@@ -648,6 +648,7 @@ class TmdbApi:
|
||||
return None
|
||||
# dict[地区:分级]
|
||||
ratings = {}
|
||||
results = []
|
||||
if results := (tmdb_info.get("release_dates") or {}).get("results"):
|
||||
"""
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user