This commit is contained in:
jxxghp 2023-06-12 07:16:01 +08:00
parent 908e9ed083
commit 1a7e272cb1
5 changed files with 49 additions and 12 deletions

View File

@ -47,7 +47,7 @@ class SearchChain(ChainBase):
return []
# 补充媒体信息
if not mediainfo.names:
mediainfo: MediaInfo = self.recognize_media(meta=MetaInfo(title=mediainfo.get_title_string()),
mediainfo: MediaInfo = self.recognize_media(meta=meta,
mtype=mediainfo.type,
tmdbid=mediainfo.tmdb_id)
if not mediainfo:
@ -90,8 +90,14 @@ 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(torrent.title, torrent.description)
torrent_meta = MetaInfo(title=title, subtitle=subtitle)
# 比对年份
if torrent_meta.year and mediainfo.year:
if mediainfo.type == MediaType.TV:

View File

@ -62,7 +62,7 @@ class SubscribeChain(ChainBase):
if not kwargs.get('total_episode'):
if not mediainfo.seasons:
# 补充媒体信息
mediainfo: MediaInfo = self.recognize_media(meta=MetaInfo(title=mediainfo.get_title_string()),
mediainfo: MediaInfo = self.recognize_media(meta=metainfo,
mtype=mediainfo.type,
tmdbid=mediainfo.tmdb_id)
if not mediainfo:
@ -188,8 +188,15 @@ class SubscribeChain(ChainBase):
logger.warn(f'{indexer.get("name")} 没有符合过滤条件的资源')
continue
for torrent in torrents:
# 识别前预处理
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(torrent.title, torrent.description)
meta = MetaInfo(title=title, subtitle=subtitle)
# 识别媒体信息
mediainfo: MediaInfo = self.recognize_media(meta=meta)
if not mediainfo:

View File

@ -47,8 +47,16 @@ class TransferChain(ChainBase):
if not torrents:
logger.error(f"没有获取到种子,参数:{arg_str}")
return False
# 识别前预处理
result: Optional[tuple] = self.prepare_recognize(title=torrents[0].get("title"))
if result:
title, subtitle = result
else:
title, subtitle = torrents[0].get("title"), None
# 识别
meta = MetaInfo(title=title, subtitle=subtitle)
# 查询媒体信息
arg_mediainfo = self.recognize_media(meta=MetaInfo(torrents[0].get("title")), tmdbid=int(tmdbid))
arg_mediainfo = self.recognize_media(meta=meta)
else:
arg_mediainfo = None
logger.info("开始执行下载器文件转移 ...")
@ -61,13 +69,19 @@ class TransferChain(ChainBase):
logger.info(f"获取到 {len(torrents)} 个已完成的下载任务")
# 识别
for torrent in torrents:
# 识别前预处理
result: Optional[tuple] = self.prepare_recognize(title=torrent.get("title"))
if result:
title, subtitle = result
else:
title, subtitle = torrent.get("title"), None
# 识别元数据
meta: MetaBase = MetaInfo(torrent.get("title"))
meta: MetaBase = MetaInfo(title=title, subtitle=subtitle)
if not meta.get_name():
logger.warn(f'未识别到元数据,标题:{torrent.get("title")}')
logger.warn(f'未识别到元数据,标题:{title}')
continue
# 识别媒体信息
if not arg_mediainfo:
# 识别媒体信息
mediainfo: MediaInfo = self.recognize_media(meta=meta)
if not mediainfo:
logger.warn(f'未识别到媒体信息,标题:{torrent.get("title")}')
@ -95,9 +109,11 @@ class TransferChain(ChainBase):
self.scrape_metadata(path=transferinfo.get('target_path'), mediainfo=mediainfo)
# 移动模式删除种子
if settings.TRANSFER_TYPE == "move":
result = self.remove_torrents(hashs=torrent.get("hash"))
if result:
result2 = self.remove_torrents(hashs=torrent.get("hash"))
if result2:
logger.info(f"移动模式删除种子成功:{torrent.get('title')} ")
# 刷新媒体库
self.refresh_mediaserver(mediainfo=mediainfo, file_path=transferinfo.get('target_path'))
# 发送通知
self.__send_transfer_message(meta=meta, mediainfo=mediainfo, transferinfo=transferinfo)

View File

@ -167,7 +167,15 @@ class UserMessageChain(ChainBase):
context: Context = cache_list[int(text) - 1]
torrent: TorrentInfo = context.torrent_info
logger.info(f"开始下载种子:{torrent.title} - {torrent.enclosure}")
meta: MetaBase = MetaInfo(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)
torrent_file, _, _, _, error_msg = self.torrent.download_torrent(
url=torrent.enclosure,
cookie=torrent.site_cookie,

View File

@ -82,7 +82,7 @@ class Command(metaclass=Singleton):
# 处理链
self.chain = CommandChian()
# 广播注册命令
self.chain.run_module("register_commands", commands=self.get_commands())
self.chain.register_commands(commands=self.get_commands())
# 消息处理线程
self._thread = Thread(target=self.__run)
# 启动事件处理线程