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