From 144bd69aea5710432a8167fc87489c4bcdd0513a Mon Sep 17 00:00:00 2001 From: bobokun Date: Sat, 26 Feb 2022 16:20:38 -0500 Subject: [PATCH] Adds tracker to cross-seed webhook #103 --- modules/qbittorrent.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/qbittorrent.py b/modules/qbittorrent.py index 7a06a66..78221df 100644 --- a/modules/qbittorrent.py +++ b/modules/qbittorrent.py @@ -601,6 +601,7 @@ class Qbt: os.makedirs(dir_cs_out, exist_ok=True) for file in cs_files: t_name = file.split(']', 2)[2].split('.torrent')[0] + t_tracker = file.split(']', 2)[1][1:] # Substring Key match in dictionary (used because t_name might not match exactly with torrentdict key) # Returned the dictionary of filtered item torrentdict_file = dict(filter(lambda item: t_name in item[0], self.torrentinfo.items())) @@ -619,6 +620,7 @@ class Qbt: body += print_line(util.insert_space(f'Torrent Name: {t_name}', 3), loglevel) body += print_line(util.insert_space(f'Category: {category}', 7), loglevel) body += print_line(util.insert_space(f'Save_Path: {dest}', 6), loglevel) + body += print_line(util.insert_space(f'Tracker: {t_tracker}', 8), loglevel) attr = { "function": "cross_seed", "title": "Adding New Cross-Seed Torrent", @@ -626,7 +628,8 @@ class Qbt: "torrent_name": t_name, "torrent_category": category, "torrent_save_path": dest, - "torrent_tag": "cross-seed" + "torrent_tag": "cross-seed", + "torrent_tracker": t_tracker } self.config.send_notifications(attr) added += 1 @@ -646,6 +649,7 @@ class Qbt: t_name = torrent.name t_cat = torrent.category if 'cross-seed' not in torrent.tags and self.torrentinfo[t_name]['count'] > 1 and self.torrentinfo[t_name]['first_hash'] != torrent.hash: + tracker = self.config.get_tags([x.url for x in torrent.trackers if x.url.startswith('http')]) tagged += 1 body = print_line(f"{'Not Adding' if dry_run else 'Adding'} 'cross-seed' tag to {t_name}", loglevel) attr = { @@ -654,7 +658,8 @@ class Qbt: "body": body, "torrent_name": t_name, "torrent_category": t_cat, - "torrent_tag": "cross-seed" + "torrent_tag": "cross-seed", + "torrent_tracker": tracker } self.config.send_notifications(attr) if not dry_run: torrent.add_tags(tags='cross-seed')