fix scrap
This commit is contained in:
parent
3d6e1335f8
commit
b43e591e4c
@ -457,17 +457,20 @@ class MediaChain(ChainBase, metaclass=Singleton):
|
|||||||
# 保存或上传nfo文件
|
# 保存或上传nfo文件
|
||||||
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.parent_fileid,
|
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.parent_fileid,
|
||||||
_path=filepath.with_suffix(".nfo"), _content=episode_nfo)
|
_path=filepath.with_suffix(".nfo"), _content=episode_nfo)
|
||||||
elif meta.begin_season:
|
else:
|
||||||
# 当前为季的目录,处理目录内的文件
|
# 当前为目录,处理目录内的文件
|
||||||
files = __list_files(_storage=storage, _fileid=fileitem.fileid,
|
files = __list_files(_storage=storage, _fileid=fileitem.fileid,
|
||||||
_drive_id=fileitem.drive_id, _path=fileitem.path)
|
_drive_id=fileitem.drive_id, _path=fileitem.path)
|
||||||
for file in files:
|
for file in files:
|
||||||
self.manual_scrape(storage=storage, fileitem=file,
|
self.manual_scrape(storage=storage, fileitem=file,
|
||||||
meta=meta, mediainfo=mediainfo,
|
meta=meta, mediainfo=mediainfo,
|
||||||
init_folder=False)
|
init_folder=False)
|
||||||
# 生成季的nfo和图片
|
# 生成目录的nfo和图片
|
||||||
if init_folder:
|
if init_folder:
|
||||||
# 季nfo
|
# 识别文件夹名称
|
||||||
|
season_meta = MetaInfo(filepath.name)
|
||||||
|
if season_meta.begin_season:
|
||||||
|
# 当前目录有季号,生成季nfo
|
||||||
season_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo, season=meta.begin_season)
|
season_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo, season=meta.begin_season)
|
||||||
if not season_nfo:
|
if not season_nfo:
|
||||||
logger.warn(f"无法生成电视剧季nfo文件:{meta.name}")
|
logger.warn(f"无法生成电视剧季nfo文件:{meta.name}")
|
||||||
@ -485,6 +488,7 @@ class MediaChain(ChainBase, metaclass=Singleton):
|
|||||||
if not seasoninfo:
|
if not seasoninfo:
|
||||||
logger.warn(f"无法获取 {mediainfo.title_year} 第{meta.begin_season}季 的媒体信息!")
|
logger.warn(f"无法获取 {mediainfo.title_year} 第{meta.begin_season}季 的媒体信息!")
|
||||||
return
|
return
|
||||||
|
# 生成季poster图片
|
||||||
if seasoninfo.get("poster_path"):
|
if seasoninfo.get("poster_path"):
|
||||||
# 下载图片
|
# 下载图片
|
||||||
content = __save_image(f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original"
|
content = __save_image(f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original"
|
||||||
@ -494,43 +498,20 @@ class MediaChain(ChainBase, metaclass=Singleton):
|
|||||||
# 保存图片文件到当前目录
|
# 保存图片文件到当前目录
|
||||||
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.fileid,
|
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.fileid,
|
||||||
_path=image_path, _content=content)
|
_path=image_path, _content=content)
|
||||||
# 季的其它图片
|
if season_meta.name:
|
||||||
for attr_name, attr_value in vars(mediainfo).items():
|
# 当前目录有名称,生成tvshow nfo 和 tv图片
|
||||||
if attr_value \
|
|
||||||
and attr_name.startswith("season") \
|
|
||||||
and not attr_name.endswith("poster_path") \
|
|
||||||
and attr_value \
|
|
||||||
and isinstance(attr_value, str) \
|
|
||||||
and attr_value.startswith("http"):
|
|
||||||
image_name = attr_name.replace("_path", "") + Path(attr_value).suffix
|
|
||||||
image_path = filepath.parent.with_name(image_name)
|
|
||||||
content = __save_image(attr_value)
|
|
||||||
# 保存图片文件到当前目录
|
|
||||||
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.fileid,
|
|
||||||
_path=image_path, _content=content)
|
|
||||||
else:
|
|
||||||
# 当前为根目录,处理目录内的文件
|
|
||||||
files = __list_files(_storage=storage, _fileid=fileitem.fileid,
|
|
||||||
_drive_id=fileitem.drive_id, _path=fileitem.path)
|
|
||||||
for file in files:
|
|
||||||
self.manual_scrape(storage=storage, fileitem=file,
|
|
||||||
meta=meta, mediainfo=mediainfo,
|
|
||||||
init_folder=False)
|
|
||||||
# 生成根目录的nfo和图片
|
|
||||||
if init_folder:
|
|
||||||
tv_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo)
|
tv_nfo = self.metadata_nfo(meta=meta, mediainfo=mediainfo)
|
||||||
if not tv_nfo:
|
if not tv_nfo:
|
||||||
logger.warn(f"无法生成电视剧nfo文件:{meta.name}")
|
logger.warn(f"无法生成电视剧nfo文件:{meta.name}")
|
||||||
return
|
return
|
||||||
# 写入nfo到根目录
|
# 写入tvshow nfo到根目录
|
||||||
nfo_path = filepath / "tvshow.nfo"
|
nfo_path = filepath / "tvshow.nfo"
|
||||||
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.fileid,
|
__save_file(_storage=storage, _drive_id=fileitem.drive_id, _fileid=fileitem.fileid,
|
||||||
_path=nfo_path, _content=tv_nfo)
|
_path=nfo_path, _content=tv_nfo)
|
||||||
# 生成根目录图片
|
# 生成目录图片
|
||||||
for attr_name, attr_value in vars(mediainfo).items():
|
for attr_name, attr_value in vars(mediainfo).items():
|
||||||
if attr_name \
|
if attr_name \
|
||||||
and attr_name.endswith("_path") \
|
and attr_name.endswith("_path") \
|
||||||
and not attr_name.startswith("season") \
|
|
||||||
and attr_value \
|
and attr_value \
|
||||||
and isinstance(attr_value, str) \
|
and isinstance(attr_value, str) \
|
||||||
and attr_value.startswith("http"):
|
and attr_value.startswith("http"):
|
||||||
|
@ -73,6 +73,15 @@ class MetaVideo(MetaBase):
|
|||||||
self.begin_episode = int(title)
|
self.begin_episode = int(title)
|
||||||
self.type = MediaType.TV
|
self.type = MediaType.TV
|
||||||
return
|
return
|
||||||
|
# 全名为Season xx 及 Sxx 直接返回
|
||||||
|
season_full_res = re.search(r"^Season\s+(\d{1,3})$|^S(\d{1,3})$", title)
|
||||||
|
if season_full_res:
|
||||||
|
self.type = MediaType.TV
|
||||||
|
season = season_full_res.group(1)
|
||||||
|
if season:
|
||||||
|
self.begin_season = int(season)
|
||||||
|
self.total_season = 1
|
||||||
|
return
|
||||||
# 去掉名称中第1个[]的内容
|
# 去掉名称中第1个[]的内容
|
||||||
title = re.sub(r'%s' % self._name_no_begin_re, "", title, count=1)
|
title = re.sub(r'%s' % self._name_no_begin_re, "", title, count=1)
|
||||||
# 把xxxx-xxxx年份换成前一个年份,常出现在季集上
|
# 把xxxx-xxxx年份换成前一个年份,常出现在季集上
|
||||||
|
Loading…
x
Reference in New Issue
Block a user