fix 尝试补充mp之外下载的download_hash
This commit is contained in:
parent
6afdfa3b97
commit
1e7f5bf04e
@ -263,8 +263,8 @@ class DirMonitor(_PluginBase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# 获取downloadhash
|
# 获取downloadhash
|
||||||
download_hash = self.get_download_hash(file_name=os.path.basename(event_path),
|
download_hash = self.get_download_hash(src=event_path,
|
||||||
tmdb_id=mediainfo.tmdb_id,)
|
tmdb_id=mediainfo.tmdb_id, )
|
||||||
|
|
||||||
# 新增转移成功历史记录
|
# 新增转移成功历史记录
|
||||||
self.transferhis.add_force(
|
self.transferhis.add_force(
|
||||||
@ -305,10 +305,11 @@ class DirMonitor(_PluginBase):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("目录监控发生错误:%s - %s" % (str(e), traceback.format_exc()))
|
logger.error("目录监控发生错误:%s - %s" % (str(e), traceback.format_exc()))
|
||||||
|
|
||||||
def get_download_hash(self, file_name, tmdb_id):
|
def get_download_hash(self, src, tmdb_id):
|
||||||
"""
|
"""
|
||||||
获取download_hash
|
获取download_hash
|
||||||
"""
|
"""
|
||||||
|
file_name = os.path.basename(src)
|
||||||
downloadHis = self.downloadhis.get_last_by(tmdbid=tmdb_id)
|
downloadHis = self.downloadhis.get_last_by(tmdbid=tmdb_id)
|
||||||
if downloadHis:
|
if downloadHis:
|
||||||
for his in downloadHis:
|
for his in downloadHis:
|
||||||
@ -328,6 +329,37 @@ class DirMonitor(_PluginBase):
|
|||||||
torrent_file_name = file.name
|
torrent_file_name = file.name
|
||||||
if str(file_name) == str(os.path.basename(torrent_file_name)):
|
if str(file_name) == str(os.path.basename(torrent_file_name)):
|
||||||
return his.download_hash
|
return his.download_hash
|
||||||
|
else:
|
||||||
|
# 尝试获取下载任务补充download_hash
|
||||||
|
logger.debug(f"转移记录 {src} 缺失download_hash,尝试补充……")
|
||||||
|
|
||||||
|
# 获取tr、qb所有种子
|
||||||
|
qb_torrents, _ = self.qb.get_torrents()
|
||||||
|
tr_torrents, _ = self.tr.get_torrents()
|
||||||
|
|
||||||
|
# 种子名称
|
||||||
|
torrent_name = str(src).split("/")[-1]
|
||||||
|
torrent_name2 = str(src).split("/")[-2]
|
||||||
|
|
||||||
|
# 处理下载器
|
||||||
|
for torrent in qb_torrents:
|
||||||
|
if str(torrent.get("name")) == str(torrent_name) \
|
||||||
|
or str(torrent.get("name")) == str(torrent_name2):
|
||||||
|
return torrent.get("hash")
|
||||||
|
|
||||||
|
# 处理辅种器 遍历所有种子,按照添加升序升序,第一个种子是初始种子
|
||||||
|
mate_torrents = []
|
||||||
|
for torrent in tr_torrents:
|
||||||
|
if str(torrent.get("name")) == str(torrent_name) \
|
||||||
|
or str(torrent.get("name")) == str(torrent_name2):
|
||||||
|
mate_torrents.append(torrent)
|
||||||
|
|
||||||
|
# 匹配上则按照时间升序
|
||||||
|
if mate_torrents:
|
||||||
|
if len(mate_torrents) > 1:
|
||||||
|
mate_torrents = sorted(mate_torrents, key=lambda x: x.added_date)
|
||||||
|
# 最早添加的hash是下载的hash
|
||||||
|
return mate_torrents[0].get("hashString")
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -343,149 +375,149 @@ class DirMonitor(_PluginBase):
|
|||||||
|
|
||||||
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
|
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'component': 'VForm',
|
'component': 'VForm',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 6
|
'md': 6
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSwitch',
|
'component': 'VSwitch',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'enabled',
|
'model': 'enabled',
|
||||||
'label': '启用插件',
|
'label': '启用插件',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 6
|
'md': 6
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSwitch',
|
'component': 'VSwitch',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'notify',
|
'model': 'notify',
|
||||||
'label': '发送通知',
|
'label': '发送通知',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 6
|
'md': 6
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSelect',
|
'component': 'VSelect',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'mode',
|
'model': 'mode',
|
||||||
'label': '监控模式',
|
'label': '监控模式',
|
||||||
'items': [
|
'items': [
|
||||||
{'title': '兼容模式', 'value': 'compatibility'},
|
{'title': '兼容模式', 'value': 'compatibility'},
|
||||||
{'title': '性能模式', 'value': 'fast'}
|
{'title': '性能模式', 'value': 'fast'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 6
|
'md': 6
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSelect',
|
'component': 'VSelect',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'transfer_type',
|
'model': 'transfer_type',
|
||||||
'label': '转移方式',
|
'label': '转移方式',
|
||||||
'items': [
|
'items': [
|
||||||
{'title': '移动', 'value': 'move'},
|
{'title': '移动', 'value': 'move'},
|
||||||
{'title': '复制', 'value': 'copy'},
|
{'title': '复制', 'value': 'copy'},
|
||||||
{'title': '硬链接', 'value': 'link'},
|
{'title': '硬链接', 'value': 'link'},
|
||||||
{'title': '软链接', 'value': 'softlink'}
|
{'title': '软链接', 'value': 'softlink'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12
|
'cols': 12
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VTextarea',
|
'component': 'VTextarea',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'monitor_dirs',
|
'model': 'monitor_dirs',
|
||||||
'label': '监控目录',
|
'label': '监控目录',
|
||||||
'rows': 5,
|
'rows': 5,
|
||||||
'placeholder': '每一行一个目录,支持两种配置方式:\n'
|
'placeholder': '每一行一个目录,支持两种配置方式:\n'
|
||||||
'监控目录\n'
|
'监控目录\n'
|
||||||
'监控目录:转移目的目录'
|
'监控目录:转移目的目录'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12
|
'cols': 12
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VTextarea',
|
'component': 'VTextarea',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'exclude_keywords',
|
'model': 'exclude_keywords',
|
||||||
'label': '排除关键词',
|
'label': '排除关键词',
|
||||||
'rows': 2,
|
'rows': 2,
|
||||||
'placeholder': '每一行一个关键词'
|
'placeholder': '每一行一个关键词'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
], {
|
], {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
"notify": False,
|
"notify": False,
|
||||||
"mode": "fast",
|
"mode": "fast",
|
||||||
"transfer_type": settings.TRANSFER_TYPE,
|
"transfer_type": settings.TRANSFER_TYPE,
|
||||||
"monitor_dirs": "",
|
"monitor_dirs": "",
|
||||||
"exclude_keywords": ""
|
"exclude_keywords": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_page(self) -> List[dict]:
|
def get_page(self) -> List[dict]:
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user