mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-11-09 16:00:53 +08:00
optimize performance
This commit is contained in:
parent
2e03283465
commit
f2db556f90
2 changed files with 16 additions and 16 deletions
|
|
@ -113,7 +113,7 @@ class Qbt:
|
||||||
if x.url.startswith('http'):
|
if x.url.startswith('http'):
|
||||||
status = x.status
|
status = x.status
|
||||||
msg = x.msg.upper()
|
msg = x.msg.upper()
|
||||||
exception = set(["DOWN", "UNREACHABLE", "BAD GATEWAY", "TRACKER UNAVAILABLE"])
|
exception = ["DOWN", "UNREACHABLE", "BAD GATEWAY", "TRACKER UNAVAILABLE"]
|
||||||
if x.status == 2:
|
if x.status == 2:
|
||||||
working_tracker = True
|
working_tracker = True
|
||||||
break
|
break
|
||||||
|
|
@ -469,7 +469,7 @@ class Qbt:
|
||||||
if cfg_rem_unregistered or cfg_tag_error:
|
if cfg_rem_unregistered or cfg_tag_error:
|
||||||
if cfg_tag_error: separator("Tagging Torrents with Tracker Errors", space=False, border=False)
|
if cfg_tag_error: separator("Tagging Torrents with Tracker Errors", space=False, border=False)
|
||||||
elif cfg_rem_unregistered: separator("Removing Unregistered Torrents", space=False, border=False)
|
elif cfg_rem_unregistered: separator("Removing Unregistered Torrents", space=False, border=False)
|
||||||
unreg_msgs = set([
|
unreg_msgs = [
|
||||||
'UNREGISTERED',
|
'UNREGISTERED',
|
||||||
'TORRENT NOT FOUND',
|
'TORRENT NOT FOUND',
|
||||||
'TORRENT IS NOT FOUND',
|
'TORRENT IS NOT FOUND',
|
||||||
|
|
@ -480,14 +480,14 @@ class Qbt:
|
||||||
'RETITLED',
|
'RETITLED',
|
||||||
'TRUNCATED',
|
'TRUNCATED',
|
||||||
'TORRENT IS NOT AUTHORIZED FOR USE ON THIS TRACKER'
|
'TORRENT IS NOT AUTHORIZED FOR USE ON THIS TRACKER'
|
||||||
])
|
]
|
||||||
ignore_msgs = set([
|
ignore_msgs = [
|
||||||
'YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT',
|
'YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT',
|
||||||
'MISSING PASSKEY',
|
'MISSING PASSKEY',
|
||||||
'MISSING INFO_HASH',
|
'MISSING INFO_HASH',
|
||||||
'PASSKEY IS INVALID',
|
'PASSKEY IS INVALID',
|
||||||
'INVALID PASSKEY'
|
'INVALID PASSKEY'
|
||||||
])
|
]
|
||||||
for torrent in self.torrentvalid:
|
for torrent in self.torrentvalid:
|
||||||
check_tags = util.get_list(torrent.tags)
|
check_tags = util.get_list(torrent.tags)
|
||||||
# Remove any error torrents Tags that are no longer unreachable.
|
# Remove any error torrents Tags that are no longer unreachable.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import logging, os, shutil, traceback, time, signal, json, re
|
import logging, os, shutil, traceback, time, signal, json
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
from ruamel import yaml
|
from ruamel import yaml
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -189,16 +189,16 @@ def add_dict_list(keys, value, dict_map):
|
||||||
dict_map[key] = [value]
|
dict_map[key] = [value]
|
||||||
|
|
||||||
|
|
||||||
def list_in_text(text, search_list, all=False):
|
def list_in_text(text, search_list, match_all=False):
|
||||||
length = len(search_list)
|
if isinstance(search_list, list): search_list = set(search_list)
|
||||||
num = 0
|
contains = set([x for x in search_list if ' ' in x])
|
||||||
pattern = re.compile(r'\b'
|
exception = search_list - contains
|
||||||
+ r'\b|\b'.join(re.escape(x) for x in search_list)
|
if match_all:
|
||||||
+ r'\b')
|
if all(x == m for m in text.split(" ") for x in exception) or all(x in text for x in contains):
|
||||||
for t in set(pattern.findall(text)):
|
return True
|
||||||
num += 1
|
else:
|
||||||
if not all: return True
|
if any(x == m for m in text.split(" ") for x in exception) or any(x in text for x in contains):
|
||||||
if(num == length and all): return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue