diff --git a/VERSION b/VERSION index 43ff51c1..0cad205d 100755 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.9-develop3 +4.0.9-develop4 diff --git a/modules/core/cross_seed.py b/modules/core/cross_seed.py index ce4cbc69..b6adc8d5 100644 --- a/modules/core/cross_seed.py +++ b/modules/core/cross_seed.py @@ -3,6 +3,7 @@ from modules import util from modules.torrent_hash_generator import TorrentHashGenerator +from modules.util import remove_extension logger = util.logger @@ -109,7 +110,7 @@ def cross_seed(self): self.notify_attr = [] # Tag missing cross-seed torrents tags for torrent in self.qbt.torrent_list: - t_name = torrent.name + t_name = remove_extension(torrent.name) t_cat = torrent.category if ( not util.is_tag_in_torrent("cross-seed", torrent.tags) diff --git a/modules/core/remove_unregistered.py b/modules/core/remove_unregistered.py index e123de0a..117e3289 100644 --- a/modules/core/remove_unregistered.py +++ b/modules/core/remove_unregistered.py @@ -4,6 +4,7 @@ from modules import util from modules.util import TorrentMessages from modules.util import list_in_text +from modules.util import remove_extension logger = util.logger @@ -209,7 +210,7 @@ def del_unregistered(self, msg, tracker, torrent): "torrent_tracker": tracker["url"], "notifiarr_indexer": tracker["notifiarr"], } - if self.qbt.torrentinfo[self.t_name]["count"] > 1: + if self.qbt.torrentinfo[remove_extension(self.t_name)]["count"] > 1: # Checks if any of the original torrents are working if "" in self.t_msg or 2 in self.t_status: attr["torrents_deleted_and_contents"] = False @@ -232,4 +233,4 @@ def del_unregistered(self, msg, tracker, torrent): attr["body"] = "\n".join(body) self.torrents_updated_unreg.append(self.t_name) self.notify_attr_unreg.append(attr) - self.qbt.torrentinfo[self.t_name]["count"] -= 1 + self.qbt.torrentinfo[remove_extension(self.t_name)]["count"] -= 1 diff --git a/modules/core/share_limits.py b/modules/core/share_limits.py index f7ef28d4..68bd814a 100644 --- a/modules/core/share_limits.py +++ b/modules/core/share_limits.py @@ -4,6 +4,7 @@ from modules import util from modules.util import is_tag_in_torrent +from modules.util import remove_extension from modules.webhooks import GROUP_NOTIFICATION_LIMIT logger = util.logger @@ -78,7 +79,7 @@ def cleanup_torrents_for_group(self, group_name, priority): t_deleted_and_contents = set() for torrent_hash, torrent_dict in self.tdel_dict.items(): torrent = torrent_dict["torrent"] - t_name = torrent.name + t_name = remove_extension(torrent.name) t_count = self.qbt.torrentinfo[t_name]["count"] t_msg = self.qbt.torrentinfo[t_name]["msg"] t_status = self.qbt.torrentinfo[t_name]["status"] diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 204ce072..04d64043 100755 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -13,6 +13,7 @@ from modules.util import Failed from modules.util import TorrentMessages from modules.util import list_in_text +from modules.util import remove_extension logger = util.logger @@ -135,7 +136,7 @@ def get_torrent_info(self): if torrent.auto_tmm is False and settings["force_auto_tmm"] and torrent.category != "" and not self.config.dry_run: torrent.set_auto_management(True) try: - torrent_name = torrent.name + torrent_name = remove_extension(torrent.name) torrent_hash = torrent.hash torrent_is_complete = torrent.state_enum.is_complete save_path = torrent.save_path diff --git a/modules/util.py b/modules/util.py index 21b31360..66f2763e 100755 --- a/modules/util.py +++ b/modules/util.py @@ -14,6 +14,63 @@ logger = logging.getLogger("qBit Manage") +def remove_extension(filename): + video_extensions = [ + ".3gp", + ".3g2", + ".asf", + ".avi", + ".divx", + ".flv", + ".m2ts", + ".m4v", + ".mkv", + ".mov", + ".mp2", + ".mp4", + ".mpe", + ".mpeg", + ".mpg", + ".mpv", + ".mts", + ".mxf", + ".ogg", + ".ogv", + ".qt", + ".rm", + ".rmvb", + ".ts", + ".vob", + ".webm", + ".wmv", + ] + audio_extensions = [ + ".aac", + ".aiff", + ".ape", + ".au", + ".flac", + ".m4a", + ".m4b", + ".mka", + ".mp3", + ".ogg", + ".opus", + ".ra", + ".rm", + ".wav", + ".wma", + ] + all_extensions = video_extensions + audio_extensions + # Split the filename into base and extension parts + base, extension = os.path.splitext(filename) + # If there's an extension, return the base part + if extension in all_extensions: + return base + else: + return filename + + def get_list(data, lower=False, split=True, int_list=False): """Return a list from a string or list.""" if data is None: @@ -277,7 +334,7 @@ def check_for_attribute( elif var_type == "float": try: data[attribute] = float(data[attribute]) - except: + except Exception: pass if isinstance(data[attribute], float) and data[attribute] >= min_int: return data[attribute]