Minor bug fixes

This commit is contained in:
Jon 2021-12-12 23:01:13 -05:00
parent 1da76debf1
commit 219da4318f
No known key found for this signature in database
GPG key ID: 9665BA6CF5DC2671
2 changed files with 25 additions and 25 deletions

View file

@ -5,13 +5,14 @@ from modules.util import Failed, print_line, print_multiline, separator
from datetime import timedelta from datetime import timedelta
from collections import Counter from collections import Counter
from fnmatch import fnmatch from fnmatch import fnmatch
from alive_progress import alive_it from alive_progress import alive_it, config_handler
logger = logging.getLogger("qBit Manage") logger = logging.getLogger("qBit Manage")
class Qbt: class Qbt:
def __init__(self, config, params): def __init__(self, config, params):
self.config = config self.config = config
config_handler.set_global(length=self.config.args['screen_width'],force_tty=True)
self.host = params["host"] self.host = params["host"]
self.username = params["username"] self.username = params["username"]
self.password = params["password"] self.password = params["password"]
@ -184,26 +185,26 @@ class Qbt:
continue continue
for torrent in alive_it(torrent_list): for torrent in alive_it(torrent_list):
tags = self.config.get_tags([x.url for x in torrent.trackers if x.url.startswith('http')]) tags = self.config.get_tags([x.url for x in torrent.trackers if x.url.startswith('http')])
if any(tag in torrent.tags for tag in nohardlinks[category]['exclude_tags']): if not nohardlinks[category]['exclude_tags']:
#Skip to the next torrent if we find any torrents that are in the exclude tag if any(tag in torrent.tags for tag in nohardlinks[category]['exclude_tags']):
continue #Skip to the next torrent if we find any torrents that are in the exclude tag
else: continue
#Checks for any hard links and not already tagged #Checks for any hard links and not already tagged
if util.nohardlink(torrent['content_path'].replace(root_dir,remote_dir)): if util.nohardlink(torrent['content_path'].replace(root_dir,remote_dir)):
#Will only tag new torrents that don't have noHL tag #Will only tag new torrents that don't have noHL tag
if 'noHL' not in torrent.tags : if 'noHL' not in torrent.tags :
num_tags += 1 num_tags += 1
print_line(util.insert_space(f'Torrent Name: {torrent.name}',3),loglevel) print_line(util.insert_space(f'Torrent Name: {torrent.name}',3),loglevel)
print_line(util.insert_space(f'Added Tag: noHL',6),loglevel) print_line(util.insert_space(f'Added Tag: noHL',6),loglevel)
print_line(util.insert_space(f'Tracker: {tags["url"]}',8),loglevel) print_line(util.insert_space(f'Tracker: {tags["url"]}',8),loglevel)
self.set_tags_and_limits(torrent, nohardlinks[category]["max_ratio"], nohardlinks[category]["max_seeding_time"],tags='noHL') self.set_tags_and_limits(torrent, nohardlinks[category]["max_ratio"], nohardlinks[category]["max_seeding_time"],tags='noHL')
#Cleans up previously tagged noHL torrents #Cleans up previously tagged noHL torrents
else: else:
# Deletes torrent with data if cleanup is set to true and meets the ratio/seeding requirements # Deletes torrent with data if cleanup is set to true and meets the ratio/seeding requirements
if (nohardlinks[category]['cleanup'] and torrent.state_enum.is_paused and len(nohardlinks[category])>0): if (nohardlinks[category]['cleanup'] and torrent.state_enum.is_paused and len(nohardlinks[category])>0):
print_line(f'Torrent Name: {torrent.name} has no hard links found and meets ratio/seeding requirements.',loglevel) print_line(f'Torrent Name: {torrent.name} has no hard links found and meets ratio/seeding requirements.',loglevel)
print_line(util.insert_space(f"Cleanup flag set to true. {'Not Deleting' if dry_run else 'Deleting'} torrent + contents.",6),loglevel) print_line(util.insert_space(f"Cleanup flag set to true. {'Not Deleting' if dry_run else 'Deleting'} torrent + contents.",6),loglevel)
tdel_dict[torrent.name] = torrent['content_path'].replace(root_dir,root_dir) tdel_dict[torrent.name] = torrent['content_path'].replace(root_dir,root_dir)
#Checks to see if previous noHL tagged torrents now have hard links. #Checks to see if previous noHL tagged torrents now have hard links.
if (not (util.nohardlink(torrent['content_path'].replace(root_dir,root_dir))) and ('noHL' in torrent.tags)): if (not (util.nohardlink(torrent['content_path'].replace(root_dir,root_dir))) and ('noHL' in torrent.tags)):
num_untag += 1 num_untag += 1

View file

@ -1,15 +1,14 @@
#!/usr/bin/python3 #!/usr/bin/python3
import argparse, logging, os, sys, fnmatch, time import argparse, logging, os, sys, time
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
from datetime import timedelta,datetime from datetime import datetime
from collections import Counter
try: try:
import schedule import schedule
from modules import util from modules import util
from modules.config import Config from modules.config import Config
from modules.util import Failed, GracefulKiller from modules.util import GracefulKiller
except ModuleNotFoundError: except ModuleNotFoundError:
print("Requirements Error: Requirements are not installed") print("Requirements Error: Requirements are not installed")
sys.exit(0) sys.exit(0)