updates cross seed to use group notifiactions

This commit is contained in:
bobokun 2023-06-04 14:32:52 -04:00
parent bf5d0621ef
commit 3f42ee5262
No known key found for this signature in database
GPG key ID: B73932169607D927
3 changed files with 32 additions and 19 deletions

View file

@ -1 +1 @@
4.0.0-develop9
4.0.0-develop10

View file

@ -15,6 +15,9 @@ class CrossSeed:
self.stats_added = 0
self.stats_tagged = 0
self.torrents_updated = [] # List of torrents added by cross-seed
self.notify_attr = [] # List of single torrent attributes to send to notifiarr
self.cross_seed()
def cross_seed(self):
@ -62,7 +65,8 @@ class CrossSeed:
"torrent_tag": "cross-seed",
"torrent_tracker": t_tracker,
}
self.config.send_notifications(attr)
self.notify_attr.append(attr)
self.torrents_updated.append(t_name)
self.stats_added += 1
if not self.config.dry_run:
self.client.torrents.add(
@ -95,6 +99,10 @@ class CrossSeed:
else:
logger.print_line(error, "WARNING")
self.config.notify(error, "cross-seed", False)
self.config.webhooks_factory.notify(self.torrents_updated, self.notify_attr, group_by="category")
self.torrents_updated = []
self.notify_attr = []
# Tag missing cross-seed torrents tags
for torrent in self.qbt.torrent_list:
t_name = torrent.name
@ -118,10 +126,11 @@ class CrossSeed:
"torrent_tag": "cross-seed",
"torrent_tracker": tracker,
}
self.config.send_notifications(attr)
self.notify_attr.append(attr)
self.torrents_updated.append(t_name)
if not self.config.dry_run:
torrent.add_tags(tags="cross-seed")
self.config.webhooks_factory.notify(self.torrents_updated, self.notify_attr, group_by="category")
numcategory = Counter(categories)
for cat in numcategory:
if numcategory[cat] > 0:

View file

@ -195,14 +195,18 @@ class Webhooks:
}
if group_by == "category":
attr["torrent_category"] = group
attr["torrent_tag"] = group_attr[group]["torrent_tag"] if only_one_torrent_updated else None
attr["torrent_tracker"] = group_attr[group]["torrent_tracker"] if only_one_torrent_updated else None
attr["notifiarr_indexer"] = group_attr[group]["notifiarr_indexer"] if only_one_torrent_updated else None
attr["torrent_tag"] = group_attr[group].get("torrent_tag") if only_one_torrent_updated else None
attr["torrent_tracker"] = group_attr[group].get("torrent_tracker") if only_one_torrent_updated else None
attr["notifiarr_indexer"] = group_attr[group].get("notifiarr_indexer") if only_one_torrent_updated else None
elif group_by == "tag":
attr["torrent_tag"] = group
attr["torrent_category"] = group_attr[group]["torrent_category"] if only_one_torrent_updated else None
attr["torrent_tracker"] = group_attr[group]["torrent_tracker"]
attr["notifiarr_indexer"] = group_attr[group]["notifiarr_indexer"]
attr["torrent_category"] = group_attr[group].get("torrent_category") if only_one_torrent_updated else None
attr["torrent_tracker"] = group_attr[group].get("torrent_tracker")
attr["notifiarr_indexer"] = group_attr[group].get("notifiarr_indexer")
for extra_attr in payload:
if extra_attr not in attr:
attr[extra_attr] = payload[extra_attr]
self.config.send_notifications(attr)
else:
@ -217,15 +221,15 @@ def group_notifications_by_key(payload, key):
group = attr[key]
if group not in group_attr:
group_attr[group] = {
"function": attr["function"],
"title": attr["title"],
"body": attr["body"],
"torrent_category": attr["torrent_category"],
"torrent_tag": attr["torrent_tag"],
"torrents": [attr["torrents"][0]],
"torrent_tracker": attr["torrent_tracker"],
"notifiarr_indexer": attr["notifiarr_indexer"],
"function": attr.get("function"),
"title": attr.get("title"),
"body": attr.get("body"),
"torrent_category": attr.get("torrent_category"),
"torrent_tag": attr.get("torrent_tag"),
"torrents": [attr.get("torrents", [None])[0]],
"torrent_tracker": attr.get("torrent_tracker"),
"notifiarr_indexer": attr.get("notifiarr_indexer"),
}
else:
group_attr[group]["torrents"].append(attr["torrents"][0])
group_attr[group]["torrents"].append(attr.get("torrents", [None])[0])
return group_attr