diff --git a/backend/src/module/database/rss.py b/backend/src/module/database/rss.py index 99a00abe9..a803d4fba 100644 --- a/backend/src/module/database/rss.py +++ b/backend/src/module/database/rss.py @@ -80,6 +80,9 @@ def search_aggregate(self) -> list[RSSItem]: select(RSSItem).where(and_(RSSItem.aggregate, RSSItem.enabled)) ).all() + def search_url(self, url: str) -> RSSItem | None: + return self.session.exec(select(RSSItem).where(RSSItem.url == url)).first() + def delete(self, _id: int) -> bool: condition = delete(RSSItem).where(RSSItem.id == _id) try: diff --git a/backend/src/module/manager/torrent.py b/backend/src/module/manager/torrent.py index cfe8d4a39..d3cab2c1a 100644 --- a/backend/src/module/manager/torrent.py +++ b/backend/src/module/manager/torrent.py @@ -40,7 +40,12 @@ def delete_rule(self, _id: int | str, file: bool = False): data = self.bangumi.search_id(int(_id)) if isinstance(data, Bangumi): with DownloadClient() as client: - self.rss.delete(data.official_title) + rss_links = filter(None, data.rss_link.split(",")) + for rss_link in rss_links: + rss = self.rss.search_url(rss_link) + if rss is None or rss.aggregate: + continue + self.rss.delete(rss.id) self.bangumi.delete_one(int(_id)) if file: torrent_message = self.delete_torrents(data, client)