fix plugin
This commit is contained in:
parent
20c4c7d6e6
commit
091df01b7c
@ -1330,7 +1330,7 @@ class BrushFlow(_PluginBase):
|
|||||||
and not int(begin_pubtime) * 60 <= pubdate_minutes <= int(end_pubtime) * 60:
|
and not int(begin_pubtime) * 60 <= pubdate_minutes <= int(end_pubtime) * 60:
|
||||||
continue
|
continue
|
||||||
# 同时下载任务数
|
# 同时下载任务数
|
||||||
downloads = self.__get_downloading_count(self._downloader)
|
downloads = self.__get_downloading_count()
|
||||||
if self._maxdlcount and downloads >= int(self._maxdlcount):
|
if self._maxdlcount and downloads >= int(self._maxdlcount):
|
||||||
logger.warn(f"当前同时下载任务数 {downloads} 已达到最大值 {self._maxdlcount},停止新增任务")
|
logger.warn(f"当前同时下载任务数 {downloads} 已达到最大值 {self._maxdlcount},停止新增任务")
|
||||||
break
|
break
|
||||||
@ -1425,24 +1425,25 @@ class BrushFlow(_PluginBase):
|
|||||||
# 检查种子状态,判断是否要删种
|
# 检查种子状态,判断是否要删种
|
||||||
remove_torrents = []
|
remove_torrents = []
|
||||||
for torrent in torrents:
|
for torrent in torrents:
|
||||||
site_name = task_info.get(self.__get_hash(torrent, self._downloader)).get("site_name")
|
torrent_hash = self.__get_hash(torrent)
|
||||||
torrent_info = self.__get_torrent_info(self._downloader, torrent)
|
site_name = task_info.get(torrent_hash).get("site_name")
|
||||||
|
torrent_info = self.__get_torrent_info(torrent)
|
||||||
# 更新上传量、下载量
|
# 更新上传量、下载量
|
||||||
if not task_info.get(torrent_info.get("hash")):
|
if not task_info.get(torrent_info.get("hash")):
|
||||||
task_info[torrent_info.get("hash")] = {
|
task_info[torrent_hash] = {
|
||||||
"downloaded": torrent_info.get("downloaded"),
|
"downloaded": torrent_info.get("downloaded"),
|
||||||
"uploaded": torrent_info.get("uploaded"),
|
"uploaded": torrent_info.get("uploaded"),
|
||||||
"ratio": torrent_info.get("ratio"),
|
"ratio": torrent_info.get("ratio"),
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
task_info[torrent_info.get("hash")]["downloaded"] = torrent_info.get("downloaded")
|
task_info[torrent_hash]["downloaded"] = torrent_info.get("downloaded")
|
||||||
task_info[torrent_info.get("hash")]["uploaded"] = torrent_info.get("uploaded")
|
task_info[torrent_hash]["uploaded"] = torrent_info.get("uploaded")
|
||||||
task_info[torrent_info.get("hash")]["ratio"] = torrent_info.get("ratio")
|
task_info[torrent_hash]["ratio"] = torrent_info.get("ratio")
|
||||||
# 做种时间(小时)
|
# 做种时间(小时)
|
||||||
if self._seed_time:
|
if self._seed_time:
|
||||||
if torrent_info.get("seeding_time") >= float(self._seed_time) * 3600:
|
if torrent_info.get("seeding_time") >= float(self._seed_time) * 3600:
|
||||||
logger.info(f"做种时间达到 {self._seed_time} 小时,删除种子:{torrent_info.get('title')}")
|
logger.info(f"做种时间达到 {self._seed_time} 小时,删除种子:{torrent_info.get('title')}")
|
||||||
downloader.delete_torrents(ids=torrent_info.get("hash"), delete_file=True)
|
downloader.delete_torrents(ids=torrent_hash, delete_file=True)
|
||||||
remove_torrents.append(torrent_info)
|
remove_torrents.append(torrent_info)
|
||||||
self.__send_delete_message(site_name=site_name,
|
self.__send_delete_message(site_name=site_name,
|
||||||
torrent_title=torrent_info.get("title"),
|
torrent_title=torrent_info.get("title"),
|
||||||
@ -1452,7 +1453,7 @@ class BrushFlow(_PluginBase):
|
|||||||
if self._seed_ratio:
|
if self._seed_ratio:
|
||||||
if torrent_info.get("ratio") >= float(self._seed_ratio):
|
if torrent_info.get("ratio") >= float(self._seed_ratio):
|
||||||
logger.info(f"分享率达到 {self._seed_ratio},删除种子:{torrent_info.get('title')}")
|
logger.info(f"分享率达到 {self._seed_ratio},删除种子:{torrent_info.get('title')}")
|
||||||
downloader.delete_torrents(ids=torrent_info.get("hash"), delete_file=True)
|
downloader.delete_torrents(ids=torrent_hash, delete_file=True)
|
||||||
remove_torrents.append(torrent_info)
|
remove_torrents.append(torrent_info)
|
||||||
self.__send_delete_message(site_name=site_name,
|
self.__send_delete_message(site_name=site_name,
|
||||||
torrent_title=torrent_info.get("title"),
|
torrent_title=torrent_info.get("title"),
|
||||||
@ -1462,7 +1463,7 @@ class BrushFlow(_PluginBase):
|
|||||||
if self._seed_size:
|
if self._seed_size:
|
||||||
if torrent_info.get("uploaded") >= float(self._seed_size) * 1024 * 1024 * 1024:
|
if torrent_info.get("uploaded") >= float(self._seed_size) * 1024 * 1024 * 1024:
|
||||||
logger.info(f"上传量达到 {self._seed_size} GB,删除种子:{torrent_info.get('title')}")
|
logger.info(f"上传量达到 {self._seed_size} GB,删除种子:{torrent_info.get('title')}")
|
||||||
downloader.delete_torrents(ids=torrent_info.get("hash"), delete_file=True)
|
downloader.delete_torrents(ids=torrent_hash, delete_file=True)
|
||||||
remove_torrents.append(torrent_info)
|
remove_torrents.append(torrent_info)
|
||||||
self.__send_delete_message(site_name=site_name,
|
self.__send_delete_message(site_name=site_name,
|
||||||
torrent_title=torrent_info.get("title"),
|
torrent_title=torrent_info.get("title"),
|
||||||
@ -1473,7 +1474,7 @@ class BrushFlow(_PluginBase):
|
|||||||
and torrent_info.get("downloaded") < torrent_info.get("total_size"):
|
and torrent_info.get("downloaded") < torrent_info.get("total_size"):
|
||||||
if torrent_info.get("dltime") >= float(self._download_time) * 3600:
|
if torrent_info.get("dltime") >= float(self._download_time) * 3600:
|
||||||
logger.info(f"下载耗时达到 {self._download_time} 小时,删除种子:{torrent_info.get('title')}")
|
logger.info(f"下载耗时达到 {self._download_time} 小时,删除种子:{torrent_info.get('title')}")
|
||||||
downloader.delete_torrents(ids=torrent_info.get("hash"), delete_file=True)
|
downloader.delete_torrents(ids=torrent_hash, delete_file=True)
|
||||||
remove_torrents.append(torrent_info)
|
remove_torrents.append(torrent_info)
|
||||||
self.__send_delete_message(site_name=site_name,
|
self.__send_delete_message(site_name=site_name,
|
||||||
torrent_title=torrent_info.get("title"),
|
torrent_title=torrent_info.get("title"),
|
||||||
@ -1483,7 +1484,7 @@ class BrushFlow(_PluginBase):
|
|||||||
if self._seed_avgspeed:
|
if self._seed_avgspeed:
|
||||||
if torrent_info.get("avg_upspeed") <= float(self._seed_avgspeed) * 1024:
|
if torrent_info.get("avg_upspeed") <= float(self._seed_avgspeed) * 1024:
|
||||||
logger.info(f"平均上传速度低于 {self._seed_avgspeed} KB/s,删除种子:{torrent_info.get('title')}")
|
logger.info(f"平均上传速度低于 {self._seed_avgspeed} KB/s,删除种子:{torrent_info.get('title')}")
|
||||||
downloader.delete_torrents(ids=torrent_info.get("hash"), delete_file=True)
|
downloader.delete_torrents(ids=torrent_hash, delete_file=True)
|
||||||
remove_torrents.append(torrent_info)
|
remove_torrents.append(torrent_info)
|
||||||
self.__send_delete_message(site_name=site_name,
|
self.__send_delete_message(site_name=site_name,
|
||||||
torrent_title=torrent_info.get("title"),
|
torrent_title=torrent_info.get("title"),
|
||||||
@ -1494,7 +1495,7 @@ class BrushFlow(_PluginBase):
|
|||||||
if torrent_info.get("iatime") >= float(self._seed_inactivetime) * 60:
|
if torrent_info.get("iatime") >= float(self._seed_inactivetime) * 60:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"未活动时间达到 {self._seed_inactivetime} 分钟,删除种子:{torrent_info.get('title')}")
|
f"未活动时间达到 {self._seed_inactivetime} 分钟,删除种子:{torrent_info.get('title')}")
|
||||||
downloader.delete_torrents(ids=torrent_info.get("hash"), delete_file=True)
|
downloader.delete_torrents(ids=torrent_hash, delete_file=True)
|
||||||
remove_torrents.append(torrent_info)
|
remove_torrents.append(torrent_info)
|
||||||
self.__send_delete_message(site_name=site_name,
|
self.__send_delete_message(site_name=site_name,
|
||||||
torrent_title=torrent_info.get("title"),
|
torrent_title=torrent_info.get("title"),
|
||||||
@ -1589,36 +1590,33 @@ class BrushFlow(_PluginBase):
|
|||||||
return torrent.hashString
|
return torrent.hashString
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
def __get_hash(self, torrent: Any):
|
||||||
def __get_hash(torrent: Any, dl_type: str):
|
|
||||||
"""
|
"""
|
||||||
获取种子hash
|
获取种子hash
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return torrent.get("hash") if dl_type == "qbittorrent" else torrent.hashString
|
return torrent.get("hash") if self._downloader == "qbittorrent" else torrent.hashString
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@staticmethod
|
def __get_label(self, torrent: Any):
|
||||||
def __get_label(torrent: Any, dl_type: str):
|
|
||||||
"""
|
"""
|
||||||
获取种子标签
|
获取种子标签
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return [str(tag).strip() for tag in torrent.get("tags").split(',')] \
|
return [str(tag).strip() for tag in torrent.get("tags").split(',')] \
|
||||||
if dl_type == "qbittorrent" else torrent.labels or []
|
if self._downloader == "qbittorrent" else torrent.labels or []
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@staticmethod
|
def __get_torrent_info(self, torrent: Any) -> dict:
|
||||||
def __get_torrent_info(downloader_type: str, torrent: Any) -> dict:
|
|
||||||
|
|
||||||
# 当前时间戳
|
# 当前时间戳
|
||||||
date_now = int(time.time())
|
date_now = int(time.time())
|
||||||
# QB
|
# QB
|
||||||
if downloader_type == "qbittorrent":
|
if self._downloader == "qbittorrent":
|
||||||
# ID
|
# ID
|
||||||
torrent_id = torrent.get("hash")
|
torrent_id = torrent.get("hash")
|
||||||
# 标题
|
# 标题
|
||||||
@ -1772,11 +1770,11 @@ class BrushFlow(_PluginBase):
|
|||||||
upload_size=info.current_stats.uploaded_bytes
|
upload_size=info.current_stats.uploaded_bytes
|
||||||
)
|
)
|
||||||
|
|
||||||
def __get_downloading_count(self, dltype: str) -> int:
|
def __get_downloading_count(self) -> int:
|
||||||
"""
|
"""
|
||||||
获取正在下载的任务数量
|
获取正在下载的任务数量
|
||||||
"""
|
"""
|
||||||
downlader = self.__get_downloader(dltype)
|
downlader = self.__get_downloader(self._downloader)
|
||||||
if not downlader:
|
if not downlader:
|
||||||
return 0
|
return 0
|
||||||
torrents = downlader.get_downloading_torrents()
|
torrents = downlader.get_downloading_torrents()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user