From 2ce622f6b9d2e7b1bce09e1777b964da466a9209 Mon Sep 17 00:00:00 2001 From: bobokun Date: Sat, 3 Jun 2023 20:43:42 -0400 Subject: [PATCH] minor fixes --- modules/core/category.py | 19 +++++++++++++++---- modules/core/tags.py | 13 ++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/core/category.py b/modules/core/category.py index 95e9207..7f5be92 100644 --- a/modules/core/category.py +++ b/modules/core/category.py @@ -74,6 +74,7 @@ class Category: "body": "\n".join(body), "torrents": [t_name], "torrent_category": new_cat, + "torrent_tag": ", ".join(tracker["tag"]), "torrent_tracker": tracker["url"], "notifiarr_indexer": tracker["notifiarr"], } @@ -92,7 +93,11 @@ class Category: if category not in group_attr: group_attr[category] = { "torrent_category": category, + "body": attr["body"], "torrents": [attr["torrents"][0]], + "torrent_tag": attr["torrent_tag"], + "torrent_tracker": attr["torrent_tracker"], + "notifiarr_indexer": attr["notifiarr_indexer"], } else: group_attr[category]["torrents"].append(attr["torrents"][0]) @@ -104,15 +109,21 @@ class Category: ) group_attr = group_notifications_by_category(self) for category in group_attr: + num_torrents_updated = len(group_attr[category]["torrents"]) + only_one_torrent_updated = num_torrents_updated == 1 + attr = { "function": "cat_update", "title": f"Updating Category for {category}", - "body": f"Updated {len(group_attr[category]['torrents'])} " - f"{'torrents' if len(group_attr[category]['torrents']) > 1 else 'torrent'} with category '{category}'", + "body": group_attr[category]["body"] + if only_one_torrent_updated + else f"Updated {num_torrents_updated} " + f"{'torrent' if only_one_torrent_updated else 'torrents'} with category '{category}'", "torrents": group_attr[category]["torrents"], "torrent_category": category, - "torrent_tracker": None, - "notifiarr_indexer": None, + "torrent_tag": group_attr[category]["torrent_tag"] if only_one_torrent_updated else None, + "torrent_tracker": group_attr[category]["torrent_tracker"] if only_one_torrent_updated else None, + "notifiarr_indexer": group_attr[category]["notifiarr_indexer"] if only_one_torrent_updated else None, } self.config.send_notifications(attr) else: diff --git a/modules/core/tags.py b/modules/core/tags.py index 9819838..cdd2756 100644 --- a/modules/core/tags.py +++ b/modules/core/tags.py @@ -69,7 +69,9 @@ class Tags: if tag not in group_attr: group_attr[tag] = { "torrent_tag": tag, + "body": attr["body"], "torrents": [attr["torrents"][0]], + "torrent_category": attr["torrent_category"], "torrent_tracker": attr["torrent_tracker"], "notifiarr_indexer": attr["notifiarr_indexer"], } @@ -83,13 +85,18 @@ class Tags: ) group_attr = group_notifications_by_tag(self) for tag in group_attr: + num_torrents_updated = len(group_attr[tag]["torrents"]) + only_one_torrent_updated = num_torrents_updated == 1 + attr = { "function": "tag_update", "title": f"Updating Tags for {tag}", - "body": f"Updated {len(group_attr[tag]['torrents'])} " - f"{'torrents' if len(group_attr[tag]['torrents']) > 1 else 'torrent'} with tag '{tag}'", + "body": group_attr[tag]["body"] + if only_one_torrent_updated + else f"Updated {num_torrents_updated} " + f"{'torrent' if only_one_torrent_updated else 'torrents'} with tag '{tag}'", "torrents": group_attr[tag]["torrents"], - "torrent_category": None, + "torrent_category": group_attr[tag]["torrent_category"] if only_one_torrent_updated else None, "torrent_tag": tag, "torrent_tracker": group_attr[tag]["torrent_tracker"], "notifiarr_indexer": group_attr[tag]["notifiarr_indexer"],