Skip to content

Commit

Permalink
Adds #756
Browse files Browse the repository at this point in the history
  • Loading branch information
bobokun committed Feb 24, 2025
1 parent e42a0c9 commit dcac299
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.19-develop6
4.1.19-develop7
3 changes: 3 additions & 0 deletions config/config.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ settings:
cat_update_all: True # Checks and updates all torrent categories if set to True when running cat_update command, otherwise only update torrents that are uncategorized
disable_qbt_default_share_limits: True # Allows QBM to handle share limits by disabling qBittorrents default Share limits. Only active when the share_limits command is set to True
tag_stalled_torrents: True # Tags any downloading torrents that are stalled with the `stalledDL` tag when running the tag_update command
rem_unregistered_ignore_list # Ignores a list of words found in the status of the tracker when running rem_unregistered command and will not remove the torrent if matched
- example placeholder words
- ignore if found

directory:
# Do not remove these
Expand Down
3 changes: 3 additions & 0 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def hooks(attr):
"tag_stalled_torrents": self.util.check_for_attribute(
self.data, "tag_stalled_torrents", parent="settings", var_type="bool", default=True
),
"rem_unregistered_ignore_list": self.util.check_for_attribute(
self.data, "rem_unregistered_ignore_list", parent="settings", var_type="upper_list", default=[]
),
}

self.tracker_error_tag = self.settings["tracker_error_tag"]
Expand Down
7 changes: 7 additions & 0 deletions modules/core/remove_unregistered.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, qbit_manager):
self.tag_error = self.config.tracker_error_tag
self.cfg_rem_unregistered = self.config.commands["rem_unregistered"]
self.cfg_tag_error = self.config.commands["tag_tracker_error"]
self.rem_unregistered_ignore_list = self.config.settings["rem_unregistered_ignore_list"]

tag_error_msg = "Tagging Torrents with Tracker Errors" if self.cfg_tag_error else ""
rem_unregistered_msg = "Removing Unregistered Torrents" if self.cfg_rem_unregistered else ""
Expand Down Expand Up @@ -125,6 +126,12 @@ def process_torrent_issues(self):
if list_in_text(msg_up, TorrentMessages.UNREGISTERED_MSGS) and not list_in_text(
msg_up, TorrentMessages.IGNORE_MSGS
):
if list_in_text(msg_up, self.rem_unregistered_ignore_list):
logger.print_line(
f"Ignoring unregistered torrent {self.t_name} due to matching phrase found in ignore list.",
self.config.loglevel,
)
continue
self.del_unregistered(msg, tracker, torrent)
else:
if self.check_for_unregistered_torrents_in_bhd(tracker, msg_up, torrent.hash):
Expand Down
10 changes: 9 additions & 1 deletion modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@
logger = logging.getLogger("qBit Manage")


def get_list(data, lower=False, split=True, int_list=False):
def get_list(data, lower=False, split=True, int_list=False, upper=False):
"""Return a list from a string or list."""
if data is None:
return None
elif isinstance(data, list):
if lower is True:
return [d.strip().lower() for d in data]
if upper is True:
return [d.strip().upper() for d in data]
return data
elif isinstance(data, dict):
return [data]
elif split is False:
return [str(data)]
elif lower is True:
return [d.strip().lower() for d in str(data).split(",")]
elif upper is True:
return [d.strip().upper() for d in str(data).split(",")]
elif int_list is True:
try:
return [int(d.strip()) for d in str(data).split(",")]
Expand Down Expand Up @@ -359,6 +365,8 @@ def check_for_attribute(
message = "No Paths exist"
elif var_type == "lower_list":
return get_list(data[attribute], lower=True)
elif var_type == "upper_list":
return get_list(data[attribute], upper=True)
elif test_list is None or data[attribute] in test_list:
return data[attribute]
else:
Expand Down

0 comments on commit dcac299

Please sign in to comment.