Skip to content

Commit

Permalink
Fixes #359
Browse files Browse the repository at this point in the history
  • Loading branch information
bobokun committed Feb 11, 2024
1 parent 1f7db1f commit 42baacd
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.9-develop3
4.0.9-develop4
3 changes: 2 additions & 1 deletion modules/core/cross_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from modules import util
from modules.torrent_hash_generator import TorrentHashGenerator
from modules.util import remove_extension

logger = util.logger

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions modules/core/remove_unregistered.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion modules/core/share_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
3 changes: 2 additions & 1 deletion modules/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
59 changes: 58 additions & 1 deletion modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 42baacd

Please sign in to comment.