Merge pull request #1882 from WangEdward/main

fix: metainfo for manual transfer
This commit is contained in:
jxxghp
2024-04-14 13:19:46 +08:00
committed by GitHub
5 changed files with 19 additions and 10 deletions

View File

@ -629,7 +629,7 @@ class DoubanModule(_ModuleBase):
return infos.get("subject_collection_items")
def scrape_metadata(self, path: Path, mediainfo: MediaInfo, transfer_type: str,
force_nfo: bool = False, force_img: bool = False) -> None:
metainfo: MetaInfo = None, force_nfo: bool = False, force_img: bool = False) -> None:
"""
刮削元数据
:param path: 媒体文件路径

View File

@ -7,6 +7,7 @@ from app import schemas
from app.core.config import settings
from app.core.context import MediaInfo
from app.core.meta import MetaBase
from app.core.metainfo import MetaInfo
from app.log import logger
from app.modules import _ModuleBase
from app.modules.themoviedb.category import CategoryHelper
@ -262,7 +263,7 @@ class TheMovieDbModule(_ModuleBase):
return []
def scrape_metadata(self, path: Path, mediainfo: MediaInfo, transfer_type: str,
force_nfo: bool = False, force_img: bool = False) -> None:
metainfo: MetaInfo = None, force_nfo: bool = False, force_img: bool = False) -> None:
"""
刮削元数据
:param path: 媒体文件路径
@ -282,6 +283,7 @@ class TheMovieDbModule(_ModuleBase):
self.scraper.gen_scraper_files(mediainfo=mediainfo,
file_path=scrape_path,
transfer_type=transfer_type,
metainfo=metainfo,
force_nfo=force_nfo,
force_img=force_img)
elif path.is_file():
@ -290,6 +292,7 @@ class TheMovieDbModule(_ModuleBase):
self.scraper.gen_scraper_files(mediainfo=mediainfo,
file_path=path,
transfer_type=transfer_type,
metainfo=metainfo,
force_nfo=force_nfo,
force_img=force_img)
else:
@ -301,6 +304,7 @@ class TheMovieDbModule(_ModuleBase):
self.scraper.gen_scraper_files(mediainfo=mediainfo,
file_path=file,
transfer_type=transfer_type,
metainfo=metainfo,
force_nfo=force_nfo,
force_img=force_img)
logger.info(f"{path} 刮削完成")

View File

@ -26,7 +26,7 @@ class TmdbScraper:
self.tmdb = tmdb
def gen_scraper_files(self, mediainfo: MediaInfo, file_path: Path, transfer_type: str,
force_nfo: bool = False, force_img: bool = False):
metainfo: MetaInfo = None, force_nfo: bool = False, force_img: bool = False):
"""
生成刮削文件包括NFO和图片传入路径为文件路径
:param mediainfo: 媒体信息
@ -75,8 +75,8 @@ class TmdbScraper:
file_path=image_path)
# 电视剧,路径为每一季的文件名 名称/Season xx/名称 SxxExx.xxx
else:
# 识别
meta = MetaInfo(file_path.stem)
# 如果有上游传入的元信息则使用,否则使用文件名识别
meta = metainfo or MetaInfo(file_path.stem)
# 根目录不存在时才处理
if self._force_nfo or not file_path.parent.with_name("tvshow.nfo").exists():
# 根目录描述文件
@ -96,7 +96,7 @@ class TmdbScraper:
self.__save_image(url=attr_value,
file_path=image_path)
# 查询季信息
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, meta.begin_season)
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, meta.begin_season or mediainfo.season)
if seasoninfo:
# 季目录NFO
if self._force_nfo or not file_path.with_name("season.nfo").exists():