optimize performance

This commit is contained in:
bobokun 2022-01-12 18:48:54 -05:00
parent 2e03283465
commit f2db556f90
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
2 changed files with 16 additions and 16 deletions

View file

@ -113,7 +113,7 @@ class Qbt:
if x.url.startswith('http'):
status = x.status
msg = x.msg.upper()
exception = set(["DOWN", "UNREACHABLE", "BAD GATEWAY", "TRACKER UNAVAILABLE"])
exception = ["DOWN", "UNREACHABLE", "BAD GATEWAY", "TRACKER UNAVAILABLE"]
if x.status == 2:
working_tracker = True
break
@ -469,7 +469,7 @@ class Qbt:
if cfg_rem_unregistered or cfg_tag_error:
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)
unreg_msgs = set([
unreg_msgs = [
'UNREGISTERED',
'TORRENT NOT FOUND',
'TORRENT IS NOT FOUND',
@ -480,14 +480,14 @@ class Qbt:
'RETITLED',
'TRUNCATED',
'TORRENT IS NOT AUTHORIZED FOR USE ON THIS TRACKER'
])
ignore_msgs = set([
]
ignore_msgs = [
'YOU HAVE REACHED THE CLIENT LIMIT FOR THIS TORRENT',
'MISSING PASSKEY',
'MISSING INFO_HASH',
'PASSKEY IS INVALID',
'INVALID PASSKEY'
])
]
for torrent in self.torrentvalid:
check_tags = util.get_list(torrent.tags)
# Remove any error torrents Tags that are no longer unreachable.

View file

@ -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 ruamel import yaml
from pathlib import Path
@ -189,16 +189,16 @@ def add_dict_list(keys, value, dict_map):
dict_map[key] = [value]
def list_in_text(text, search_list, all=False):
length = len(search_list)
num = 0
pattern = re.compile(r'\b'
+ r'\b|\b'.join(re.escape(x) for x in search_list)
+ r'\b')
for t in set(pattern.findall(text)):
num += 1
if not all: return True
if(num == length and all): return True
def list_in_text(text, search_list, match_all=False):
if isinstance(search_list, list): search_list = set(search_list)
contains = set([x for x in search_list if ' ' in x])
exception = search_list - contains
if match_all:
if all(x == m for m in text.split(" ") for x in exception) or all(x in text for x in contains):
return True
else:
if any(x == m for m in text.split(" ") for x in exception) or any(x in text for x in contains):
return True
return False