fix DirMonitor
This commit is contained in:
@ -94,16 +94,6 @@ class ChainBase(metaclass=ABCMeta):
|
||||
logger.error(f"运行模块 {method} 出错:{module.__class__.__name__} - {err}\n{traceback.print_exc()}")
|
||||
return result
|
||||
|
||||
def prepare_recognize(self, title: str,
|
||||
subtitle: str = None) -> Tuple[str, str]:
|
||||
"""
|
||||
处理各类特别命名,以便识别
|
||||
:param title: 标题
|
||||
:param subtitle: 副标题
|
||||
:return: 处理后的标题、副标题,该方法可被多个模块同时处理
|
||||
"""
|
||||
return self.run_module("prepare_recognize", title=title, subtitle=subtitle)
|
||||
|
||||
def recognize_media(self, meta: MetaBase = None,
|
||||
mtype: MediaType = None,
|
||||
tmdbid: int = None) -> Optional[MediaInfo]:
|
||||
|
@ -18,10 +18,6 @@ class MediaChain(ChainBase):
|
||||
根据主副标题识别媒体信息
|
||||
"""
|
||||
logger.info(f'开始识别媒体信息,标题:{title},副标题:{subtitle} ...')
|
||||
# 识别前预处理
|
||||
result: Optional[tuple] = self.prepare_recognize(title=title, subtitle=subtitle)
|
||||
if result:
|
||||
title, subtitle = result
|
||||
# 识别元数据
|
||||
metainfo = MetaInfo(title, subtitle)
|
||||
# 识别媒体信息
|
||||
|
@ -157,14 +157,8 @@ class SearchChain(ChainBase):
|
||||
logger.info(f'{mediainfo.title} 匹配到资源:{torrent.site_name} - {torrent.title}')
|
||||
_match_torrents.append(torrent)
|
||||
continue
|
||||
# 识别前预处理
|
||||
result: Optional[tuple] = self.prepare_recognize(title=torrent.title, subtitle=torrent.description)
|
||||
if result:
|
||||
title, subtitle = result
|
||||
else:
|
||||
title, subtitle = torrent.title, torrent.description
|
||||
# 识别
|
||||
torrent_meta = MetaInfo(title=title, subtitle=subtitle)
|
||||
torrent_meta = MetaInfo(title=torrent.title, subtitle=torrent.description)
|
||||
# 比对类型
|
||||
if torrent_meta.type == MediaType.TV and mediainfo.type != MediaType.TV:
|
||||
logger.warn(f'{torrent.site_name} - {torrent.title} 类型不匹配')
|
||||
|
@ -52,10 +52,6 @@ class SubscribeChain(ChainBase):
|
||||
识别媒体信息并添加订阅
|
||||
"""
|
||||
logger.info(f'开始添加订阅,标题:{title} ...')
|
||||
# 识别前预处理
|
||||
result: Optional[tuple] = self.prepare_recognize(title=title)
|
||||
if result:
|
||||
title, _ = result
|
||||
# 识别元数据
|
||||
metainfo = MetaInfo(title)
|
||||
if year:
|
||||
@ -385,15 +381,8 @@ class SubscribeChain(ChainBase):
|
||||
continue
|
||||
for torrent in torrents:
|
||||
logger.info(f'处理资源:{torrent.title} ...')
|
||||
# 识别前预处理
|
||||
result: Optional[tuple] = self.prepare_recognize(title=torrent.title,
|
||||
subtitle=torrent.description)
|
||||
if result:
|
||||
title, subtitle = result
|
||||
else:
|
||||
title, subtitle = torrent.title, torrent.description
|
||||
# 识别
|
||||
meta = MetaInfo(title=title, subtitle=subtitle)
|
||||
meta = MetaInfo(title=torrent.title, subtitle=torrent.description)
|
||||
# 识别媒体信息
|
||||
mediainfo: MediaInfo = self.recognize_media(meta=meta)
|
||||
if not mediainfo:
|
||||
|
@ -89,16 +89,10 @@ class TransferChain(ChainBase):
|
||||
self.progress.update(value=processed_num / total_num * 100,
|
||||
text=f"正在转移 {torrent.title} ...",
|
||||
key=ProgressKey.FileTransfer)
|
||||
# 识别前预处理
|
||||
result: Optional[tuple] = self.prepare_recognize(title=torrent.title)
|
||||
if result:
|
||||
title, subtitle = result
|
||||
else:
|
||||
title, subtitle = torrent.title, None
|
||||
# 识别元数据
|
||||
meta: MetaBase = MetaInfo(title=title, subtitle=subtitle)
|
||||
meta: MetaBase = MetaInfo(title=torrent.title)
|
||||
if not meta.name:
|
||||
logger.error(f'未识别到元数据,标题:{title}')
|
||||
logger.error(f'未识别到元数据,标题:{torrent.title}')
|
||||
continue
|
||||
if not arg_mediainfo:
|
||||
# 查询下载记录识别情况
|
||||
@ -110,7 +104,7 @@ class TransferChain(ChainBase):
|
||||
if mtype == MediaType.TV \
|
||||
and ((not meta.season_list and downloadhis.seasons)
|
||||
or (not meta.episode_list and downloadhis.episodes)):
|
||||
meta = MetaInfo(f"{title} {downloadhis.seasons} {downloadhis.episodes}")
|
||||
meta = MetaInfo(f"{torrent.title} {downloadhis.seasons} {downloadhis.episodes}")
|
||||
# 按TMDBID识别
|
||||
mediainfo = self.recognize_media(mtype=mtype,
|
||||
tmdbid=downloadhis.tmdbid)
|
||||
@ -195,7 +189,7 @@ class TransferChain(ChainBase):
|
||||
)
|
||||
# 转移完成
|
||||
self.transfer_completed(hashs=torrent.hash, transinfo=transferinfo)
|
||||
# 刮剥
|
||||
# 刮削元数据
|
||||
self.scrape_metadata(path=transferinfo.target_path, mediainfo=mediainfo)
|
||||
# 刷新媒体库
|
||||
self.refresh_mediaserver(mediainfo=mediainfo, file_path=transferinfo.target_path)
|
||||
|
Reference in New Issue
Block a user