mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2026-01-06 08:14:11 +08:00
more refactoring
This commit is contained in:
parent
b141c1f669
commit
04134d3c0a
4 changed files with 58 additions and 46 deletions
|
|
@ -39,7 +39,7 @@ class CrossSeed:
|
|||
dest = os.path.join(self.qbt.torrentinfo[t_name]["save_path"], "")
|
||||
src = os.path.join(dir_cs, file)
|
||||
dir_cs_out = os.path.join(dir_cs, "qbit_manage_added", file)
|
||||
category = self.get_category(dest)
|
||||
category = self.qbt.global_max_ratioget_category(dest)
|
||||
# Only add cross-seed torrent if original torrent is complete
|
||||
if self.qbt.torrentinfo[t_name]["is_complete"]:
|
||||
categories.append(category)
|
||||
|
|
|
|||
|
|
@ -2,38 +2,12 @@ from qbittorrentapi import NotFound404Error
|
|||
|
||||
from modules import util
|
||||
from modules.util import list_in_text
|
||||
from modules.util import TorrentMessages
|
||||
|
||||
logger = util.logger
|
||||
|
||||
|
||||
class RemoveUnregistered:
|
||||
UNREGISTERED_MSGS = [
|
||||
"UNREGISTERED",
|
||||
"TORRENT NOT FOUND",
|
||||
"TORRENT IS NOT FOUND",
|
||||
"NOT REGISTERED",
|
||||
"NOT EXIST",
|
||||
"UNKNOWN TORRENT",
|
||||
"TRUMP",
|
||||
"RETITLED",
|
||||
"TRUNCATED",
|
||||
"TORRENT IS NOT AUTHORIZED FOR USE ON THIS TRACKER",
|
||||
]
|
||||
|
||||
IGNORE_MSGS = [
|
||||
"YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT",
|
||||
"MISSING PASSKEY",
|
||||
"MISSING INFO_HASH",
|
||||
"PASSKEY IS INVALID",
|
||||
"INVALID PASSKEY",
|
||||
"EXPECTED VALUE (LIST, DICT, INT OR STRING) IN BENCODED STRING",
|
||||
"COULD NOT PARSE BENCODED DATA",
|
||||
"STREAM TRUNCATED",
|
||||
]
|
||||
|
||||
# Tracker has been contacted, but it is not working (or doesn't send proper replies)
|
||||
TORRENT_STATUS_NOT_WORKING = 4
|
||||
|
||||
def __init__(self, qbit_manager):
|
||||
self.qbt = qbit_manager
|
||||
self.config = qbit_manager.config
|
||||
|
|
@ -98,20 +72,20 @@ class RemoveUnregistered:
|
|||
msg = trk.msg
|
||||
# Tag any error torrents
|
||||
if self.cfg_tag_error:
|
||||
if trk.status == self.TORRENT_STATUS_NOT_WORKING and self.tag_error not in check_tags:
|
||||
if trk.status == TorrentMessages.TORRENT_STATUS_NOT_WORKING and self.tag_error not in check_tags:
|
||||
self.tag_tracker_error()
|
||||
if self.cfg_rem_unregistered:
|
||||
# Tag any error torrents that are not unregistered
|
||||
if (
|
||||
not list_in_text(msg_up, self.UNREGISTERED_MSGS)
|
||||
and trk.status == self.TORRENT_STATUS_NOT_WORKING
|
||||
not list_in_text(msg_up, TorrentMessages.UNREGISTERED_MSGS)
|
||||
and trk.status == TorrentMessages.TORRENT_STATUS_NOT_WORKING
|
||||
and self.tag_error not in check_tags
|
||||
):
|
||||
# Check for unregistered torrents using BHD API if the tracker is BHD
|
||||
if (
|
||||
"tracker.beyond-hd.me" in tracker["url"]
|
||||
and self.config.beyond_hd is not None
|
||||
and not list_in_text(msg_up, self.IGNORE_MSGS)
|
||||
and not list_in_text(msg_up, TorrentMessages.IGNORE_MSGS)
|
||||
):
|
||||
json = {"info_hash": torrent.hash}
|
||||
response = self.config.beyond_hd.search(json)
|
||||
|
|
@ -120,9 +94,9 @@ class RemoveUnregistered:
|
|||
break
|
||||
self.tag_tracker_error()
|
||||
if (
|
||||
list_in_text(msg_up, self.UNREGISTERED_MSGS)
|
||||
and not list_in_text(msg_up, self.IGNORE_MSGS)
|
||||
and trk.status == self.TORRENT_STATUS_NOT_WORKING
|
||||
list_in_text(msg_up, TorrentMessages.UNREGISTERED_MSGS)
|
||||
and not list_in_text(msg_up, TorrentMessages.IGNORE_MSGS)
|
||||
and trk.status == TorrentMessages.TORRENT_STATUS_NOT_WORKING
|
||||
):
|
||||
self.del_unregistered()
|
||||
break
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from qbittorrentapi import Version
|
|||
from modules import util
|
||||
from modules.util import Failed
|
||||
from modules.util import list_in_text
|
||||
from modules.util import TorrentMessages
|
||||
|
||||
logger = util.logger
|
||||
|
||||
|
|
@ -157,20 +158,13 @@ class Qbt:
|
|||
if trk.url.startswith("http"):
|
||||
status = trk.status
|
||||
msg = trk.msg.upper()
|
||||
exception = [
|
||||
"DOWN",
|
||||
"DOWN.",
|
||||
"IT MAY BE DOWN,",
|
||||
"UNREACHABLE",
|
||||
"(UNREACHABLE)",
|
||||
"BAD GATEWAY",
|
||||
"TRACKER UNAVAILABLE",
|
||||
]
|
||||
if trk.status == 2:
|
||||
if trk.status == TorrentMessages.TORRENT_STATUS_WORKING:
|
||||
working_tracker = True
|
||||
break
|
||||
# Add any potential unregistered torrents to a list
|
||||
if trk.status == 4 and not list_in_text(msg, exception):
|
||||
if trk.status == TorrentMessages.TORRENT_STATUS_NOT_WORKING and not list_in_text(
|
||||
msg, TorrentMessages.EXCEPTIONS_MSGS
|
||||
):
|
||||
issue["potential"] = True
|
||||
issue["msg"] = msg
|
||||
issue["status"] = status
|
||||
|
|
|
|||
|
|
@ -33,6 +33,50 @@ def get_list(data, lower=False, split=True, int_list=False):
|
|||
return [d.strip() for d in str(data).split(",")]
|
||||
|
||||
|
||||
class TorrentMessages:
|
||||
"""Contains list of messages to check against a status of a torrent"""
|
||||
|
||||
UNREGISTERED_MSGS = [
|
||||
"UNREGISTERED",
|
||||
"TORRENT NOT FOUND",
|
||||
"TORRENT IS NOT FOUND",
|
||||
"NOT REGISTERED",
|
||||
"NOT EXIST",
|
||||
"UNKNOWN TORRENT",
|
||||
"TRUMP",
|
||||
"RETITLED",
|
||||
"TRUNCATED",
|
||||
"TORRENT IS NOT AUTHORIZED FOR USE ON THIS TRACKER",
|
||||
]
|
||||
|
||||
IGNORE_MSGS = [
|
||||
"YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT",
|
||||
"MISSING PASSKEY",
|
||||
"MISSING INFO_HASH",
|
||||
"PASSKEY IS INVALID",
|
||||
"INVALID PASSKEY",
|
||||
"EXPECTED VALUE (LIST, DICT, INT OR STRING) IN BENCODED STRING",
|
||||
"COULD NOT PARSE BENCODED DATA",
|
||||
"STREAM TRUNCATED",
|
||||
]
|
||||
|
||||
EXCEPTIONS_MSGS = [
|
||||
"DOWN",
|
||||
"DOWN.",
|
||||
"IT MAY BE DOWN,",
|
||||
"UNREACHABLE",
|
||||
"(UNREACHABLE)",
|
||||
"BAD GATEWAY",
|
||||
"TRACKER UNAVAILABLE",
|
||||
]
|
||||
|
||||
TORRENT_STATUS_DISABLED = 0 # Tracker is disabled (used for DHT, PeX, and LSD)
|
||||
TORRENT_STATUS_NOT_CONTACTED = 1 # Tracker has not been contacted yet
|
||||
TORRENT_STATUS_WORKING = 2 # Tracker has been contacted and is working
|
||||
TORRENT_STATUS_UPDATING = 3 # Tracker is updating
|
||||
TORRENT_STATUS_NOT_WORKING = 4 # Tracker has been contacted, but it is not working (or doesn't send proper replies)
|
||||
|
||||
|
||||
class check:
|
||||
"""Check for attributes in config."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue