From 57fa0b0c412403577cdb9461afd3ea786ae6e78d Mon Sep 17 00:00:00 2001 From: bobokun Date: Tue, 22 Nov 2022 20:46:32 -0500 Subject: [PATCH] Changes default share limits to -1 if not defined --- config/config.yml.sample | 10 +++++----- modules/config.py | 36 ++++++++++++++++++++---------------- modules/qbittorrent.py | 16 +++++----------- modules/util.py | 14 ++++++++------ 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/config/config.yml.sample b/config/config.yml.sample index 6914a17..48aa541 100755 --- a/config/config.yml.sample +++ b/config/config.yml.sample @@ -72,7 +72,7 @@ tracker: # max_seeding_time: 129600 # Will ensure that noHL torrents from this tracker are not deleted by cleanup variable if torrent has not yet met the minimum seeding time (min). # min_seeding_time: 2000 - # Will limit the upload speed KiB/s (KiloBytes/second) (-1 sets the limit to infinity) + # Will limit the upload speed KiB/s (KiloBytes/second) (-1 means no limit) # limit_upload_speed: 150 # Set this to the notifiarr react name. This is used to add indexer reactions to the notifications sent by Notifiarr # notifiarr: @@ -140,7 +140,7 @@ nohardlinks: - Beyond-HD - AnimeBytes - MaM - # cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that are in paused state and has the NoHL tag + # cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that have a noHL tag and meets share limits cleanup: false # max_ratio var: Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading max_ratio: 4.0 @@ -151,7 +151,7 @@ nohardlinks: # min seeding time var: Will prevent torrent deletion by cleanup variable if torrent has not yet minimum seeding time (min). # Delete this key from a category's config to use the tracker's configured min_seeding_time. Will default to 0 if not specified for the category or tracker. min_seeding_time: 43200 - # resume_torrent_after_untagging_noHL var: If a torrent was previously tagged as NoHL and now has hardlinks, this variable will resume your torrent after restoring original share limits + # resume_torrent_after_untagging_noHL var: If a torrent was previously tagged as NoHL and now has hardlinks, this variable will resume your torrent after changing share limits resume_torrent_after_untagging_noHL: false # Can have additional categories set with separate ratio/seeding times defined. series-completed: @@ -159,7 +159,7 @@ nohardlinks: exclude_tags: - Beyond-HD - BroadcasTheNet - # cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that are in paused state and has the NoHL tag + # cleanup var: WARNING!! Setting this as true Will remove and delete contents of any torrents that have a noHL tag and meets share limits cleanup: false # max_ratio var: Will set the torrent Maximum share ratio until torrent is stopped from seeding/uploading max_ratio: 4.0 @@ -169,7 +169,7 @@ nohardlinks: limit_upload_speed: # min seeding time var: Will prevent torrent deletion by cleanup variable if torrent has not yet minimum seeding time (min). # min_seeding_time: # Not specified for this category; tracker's value will be used. Will default to 0 if not specified for the category or tracker. - # resume_torrent_after_untagging_noHL var: If a torrent was previously tagged as NoHL and now has hardlinks, this variable will resume your torrent after restoring original share limits + # resume_torrent_after_untagging_noHL var: If a torrent was previously tagged as NoHL and now has hardlinks, this variable will resume your torrent after changing share limits resume_torrent_after_untagging_noHL: false recyclebin: diff --git a/modules/config.py b/modules/config.py index 94616f3..eaa32c9 100755 --- a/modules/config.py +++ b/modules/config.py @@ -256,9 +256,9 @@ class Config: parent="nohardlinks", subparent=cat, var_type="float", - default_int=-2, - default_is_none=True, + min_int=-2, do_print=False, + default=-1, ) self.nohardlinks[cat]["max_seeding_time"] = self.util.check_for_attribute( self.data, @@ -266,9 +266,10 @@ class Config: parent="nohardlinks", subparent=cat, var_type="int", - default_int=-2, - default_is_none=True, + min_int=-2, do_print=False, + default=-1, + save=False, ) self.nohardlinks[cat]["min_seeding_time"] = self.util.check_for_attribute( self.data, @@ -276,9 +277,10 @@ class Config: parent="nohardlinks", subparent=cat, var_type="int", - default_int=0, - default_is_none=True, + min_int=0, do_print=False, + default=0, + save=False, ) self.nohardlinks[cat]["limit_upload_speed"] = self.util.check_for_attribute( self.data, @@ -286,9 +288,10 @@ class Config: parent="nohardlinks", subparent=cat, var_type="int", - default_int=-1, - default_is_none=True, + min_int=-1, do_print=False, + default=-1, + save=False, ) self.nohardlinks[cat]["resume_torrent_after_untagging_noHL"] = self.util.check_for_attribute( self.data, @@ -298,6 +301,7 @@ class Config: var_type="bool", default=True, do_print=False, + save=False, ) else: e = f"Config Error: Category {cat} is defined under nohardlinks attribute " @@ -491,9 +495,9 @@ class Config: parent="tracker", subparent=tag_url, var_type="float", - default_int=-2, - default_is_none=True, + min_int=-2, do_print=False, + default=-1, save=False, ) tracker["min_seeding_time"] = self.util.check_for_attribute( @@ -502,9 +506,9 @@ class Config: parent="tracker", subparent=tag_url, var_type="int", - default_int=0, - default_is_none=True, + min_int=0, do_print=False, + default=-1, save=False, ) tracker["max_seeding_time"] = self.util.check_for_attribute( @@ -513,9 +517,9 @@ class Config: parent="tracker", subparent=tag_url, var_type="int", - default_int=-2, - default_is_none=True, + min_int=-2, do_print=False, + default=-1, save=False, ) tracker["limit_upload_speed"] = self.util.check_for_attribute( @@ -524,9 +528,9 @@ class Config: parent="tracker", subparent=tag_url, var_type="int", - default_int=-1, - default_is_none=True, + min_int=-1, do_print=False, + default=0, save=False, ) tracker["notifiarr"] = self.util.check_for_attribute( diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 5eb1aab..97d183c 100755 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -255,7 +255,7 @@ class Qbt: if self.config.commands["cat_update"]: logger.separator("Updating Categories", space=False, border=False) - torrent_list = self.get_torrents({"category": "", "filter": "completed"}) + torrent_list = self.get_torrents({"category": "", "status_filter": "completed"}) for torrent in torrent_list: new_cat = self.config.get_category(torrent.save_path) update_cat(new_cat, False) @@ -263,7 +263,7 @@ class Qbt: # Change categories if self.config.cat_change: for old_cat in self.config.cat_change: - torrent_list = self.get_torrents({"category": old_cat, "filter": "completed"}) + torrent_list = self.get_torrents({"category": old_cat, "status_filter": "completed"}) for torrent in torrent_list: new_cat = self.config.cat_change[old_cat] update_cat(new_cat, True) @@ -333,13 +333,7 @@ class Qbt: ): body = [] if limit_upload_speed: - if limit_upload_speed == -1: - msg = logger.insert_space("Limit UL Speed: Infinity", 1) - if do_print: - body += logger.print_line(msg, self.config.loglevel) - else: - body.append(msg) - else: + if limit_upload_speed != -1: msg = logger.insert_space(f"Limit UL Speed: {limit_upload_speed} kB/s", 1) if do_print: body += logger.print_line(msg, self.config.loglevel) @@ -515,7 +509,7 @@ class Qbt: root_dir = self.config.root_dir remote_dir = self.config.remote_dir for category in nohardlinks: - torrent_list = self.get_torrents({"category": category, "filter": "completed"}) + torrent_list = self.get_torrents({"category": category, "status_filter": "completed"}) if len(torrent_list) == 0: e = ( "No torrents found in the category (" @@ -611,7 +605,7 @@ class Qbt: self.config.send_notifications(attr) # loop through torrent list again for cleanup purposes if nohardlinks[category]["cleanup"]: - torrent_list = self.get_torrents({"category": category, "filter": "completed"}) + torrent_list = self.get_torrents({"category": category, "status_filter": "completed"}) for torrent in torrent_list: t_name = torrent.name if t_name in tdel_dict.keys() and "noHL" in torrent.tags: diff --git a/modules/util.py b/modules/util.py index 6b6a4b1..a7cf798 100755 --- a/modules/util.py +++ b/modules/util.py @@ -47,7 +47,7 @@ class check: default_is_none=False, req_default=False, var_type="str", - default_int=0, + min_int=0, throw=False, save=True, make_dirs=False, @@ -119,19 +119,21 @@ class check: else: message = f"{text} must be either true or false" elif var_type == "int": - if isinstance(data[attribute], int) and data[attribute] >= default_int: + if isinstance(data[attribute], int) and data[attribute] >= min_int: return data[attribute] else: - message = f"{text} must an integer >= {default_int}" + message = f"{text} must an integer >= {min_int}" + throw = True elif var_type == "float": try: data[attribute] = float(data[attribute]) except: pass - if isinstance(data[attribute], float) and data[attribute] >= default_int: + if isinstance(data[attribute], float) and data[attribute] >= min_int: return data[attribute] else: - message = f"{text} must a float >= {float(default_int)}" + message = f"{text} must a float >= {float(min_int)}" + throw = True elif var_type == "path": if os.path.exists(os.path.abspath(data[attribute])): return os.path.join(data[attribute], "") @@ -162,7 +164,7 @@ class check: else: message = f"no {text} found and the default path {default} could not be found" default = None - if default is not None or default_is_none: + if (default is not None or default_is_none) and not message: message = message + f" using {default} as default" message = message + endline if req_default and default is None: