mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
Merge pull request #5399 from cddjr/fix_downloader_monitor
This commit is contained in:
+21
-16
@@ -294,6 +294,17 @@ class JobManager:
|
|||||||
media_success = True
|
media_success = True
|
||||||
return meta_success and media_success
|
return meta_success and media_success
|
||||||
|
|
||||||
|
def get_all_torrent_hashes(self) -> set[str]:
|
||||||
|
"""
|
||||||
|
获取所有种子的哈希值集合
|
||||||
|
"""
|
||||||
|
with job_lock:
|
||||||
|
return {
|
||||||
|
task.download_hash
|
||||||
|
for job in self._job_view.values()
|
||||||
|
for task in job.tasks
|
||||||
|
}
|
||||||
|
|
||||||
def is_torrent_done(self, download_hash: str) -> bool:
|
def is_torrent_done(self, download_hash: str) -> bool:
|
||||||
"""
|
"""
|
||||||
检查指定种子的所有任务是否都已完成
|
检查指定种子的所有任务是否都已完成
|
||||||
@@ -959,7 +970,16 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
|
|||||||
logger.info("开始整理下载器中已经完成下载的文件 ...")
|
logger.info("开始整理下载器中已经完成下载的文件 ...")
|
||||||
|
|
||||||
# 从下载器获取种子列表
|
# 从下载器获取种子列表
|
||||||
torrents: Optional[List[TransferTorrent]] = self.list_torrents(status=TorrentStatus.TRANSFER)
|
if torrents_list := self.list_torrents(status=TorrentStatus.TRANSFER):
|
||||||
|
existing_hashes = self.jobview.get_all_torrent_hashes()
|
||||||
|
torrents = [
|
||||||
|
torrent
|
||||||
|
for torrent in torrents_list
|
||||||
|
if torrent.hash not in existing_hashes
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
torrents = []
|
||||||
|
|
||||||
if not torrents:
|
if not torrents:
|
||||||
logger.info("没有已完成下载但未整理的任务")
|
logger.info("没有已完成下载但未整理的任务")
|
||||||
return False
|
return False
|
||||||
@@ -994,20 +1014,11 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
|
|||||||
# 查询下载记录识别情况
|
# 查询下载记录识别情况
|
||||||
downloadhis: DownloadHistory = DownloadHistoryOper().get_by_hash(torrent.hash)
|
downloadhis: DownloadHistory = DownloadHistoryOper().get_by_hash(torrent.hash)
|
||||||
if downloadhis:
|
if downloadhis:
|
||||||
# 获取自定义识别词
|
|
||||||
custom_words_list = None
|
|
||||||
if downloadhis.custom_words:
|
|
||||||
custom_words_list = downloadhis.custom_words.split('\n')
|
|
||||||
|
|
||||||
# 类型
|
# 类型
|
||||||
try:
|
try:
|
||||||
mtype = MediaType(downloadhis.type)
|
mtype = MediaType(downloadhis.type)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
mtype = MediaType.TV
|
mtype = MediaType.TV
|
||||||
|
|
||||||
# 识别元数据
|
|
||||||
metainfo = MetaInfoPath(file_path, custom_words=custom_words_list)
|
|
||||||
|
|
||||||
# 识别媒体信息
|
# 识别媒体信息
|
||||||
mediainfo = self.recognize_media(mtype=mtype,
|
mediainfo = self.recognize_media(mtype=mtype,
|
||||||
tmdbid=downloadhis.tmdbid,
|
tmdbid=downloadhis.tmdbid,
|
||||||
@@ -1022,14 +1033,8 @@ class TransferChain(ChainBase, ConfigReloadMixin, metaclass=Singleton):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# 非MoviePilot下载的任务,按文件识别
|
# 非MoviePilot下载的任务,按文件识别
|
||||||
metainfo = MetaInfoPath(file_path)
|
|
||||||
mediainfo = None
|
mediainfo = None
|
||||||
|
|
||||||
# 检查是否已经有任务处理中,如有则跳过本次整理
|
|
||||||
if self.jobview.has_tasks(meta=metainfo, mediainfo=mediainfo):
|
|
||||||
logger.info(f"有任务正在整理中,跳过本次整理 ...")
|
|
||||||
return False
|
|
||||||
|
|
||||||
# 执行异步整理,匹配源目录
|
# 执行异步整理,匹配源目录
|
||||||
self.do_transfer(
|
self.do_transfer(
|
||||||
fileitem=FileItem(
|
fileitem=FileItem(
|
||||||
|
|||||||
Reference in New Issue
Block a user