From bdb3126d8ebf1f5d4306684f1547374c7fd96789 Mon Sep 17 00:00:00 2001 From: EstrellaXD Date: Tue, 25 Apr 2023 21:05:13 +0800 Subject: [PATCH] Add filter switch --- src/module/core/api_func.py | 2 +- src/module/network/request_contents.py | 7 +++++-- src/module/rss/rss_analyser.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/module/core/api_func.py b/src/module/core/api_func.py index fae3b2d4..1baa1a28 100644 --- a/src/module/core/api_func.py +++ b/src/module/core/api_func.py @@ -21,7 +21,7 @@ class APIProcess: self._full_season_get = FullSeasonGet() def link_process(self, link): - return self._rss_analyser.rss_to_data(link) + return self._rss_analyser.rss_to_data(link, filter=False) @api_failed def download_collection(self, link): diff --git a/src/module/network/request_contents.py b/src/module/network/request_contents.py index 078d8dca..4f621d38 100644 --- a/src/module/network/request_contents.py +++ b/src/module/network/request_contents.py @@ -19,13 +19,16 @@ class TorrentInfo: class RequestContent(RequestURL): # Mikanani RSS - def get_torrents(self, _url: str) -> [TorrentInfo]: + def get_torrents(self, _url: str, filter: bool = True) -> [TorrentInfo]: soup = self.get_xml(_url) torrent_titles = [item.title.string for item in soup.find_all("item")] torrent_urls = [item.get("url") for item in soup.find_all("enclosure")] torrents = [] for _title, torrent_url in zip(torrent_titles, torrent_urls): - if re.search(FILTER, _title) is None: + if filter: + if re.search(FILTER, _title) is None: + torrents.append(TorrentInfo(_title, torrent_url)) + else: torrents.append(TorrentInfo(_title, torrent_url)) return torrents diff --git a/src/module/rss/rss_analyser.py b/src/module/rss/rss_analyser.py index b833b7b1..8acc1306 100644 --- a/src/module/rss/rss_analyser.py +++ b/src/module/rss/rss_analyser.py @@ -33,9 +33,9 @@ class RSSAnalyser: bangumi_info.append(data) return bangumi_info - def rss_to_data(self, url) -> dict: + def rss_to_data(self, url, filter: bool = True) -> dict: with RequestContent() as req: - rss_torrents = req.get_torrents(url) + rss_torrents = req.get_torrents(url, filter) for torrent in rss_torrents: try: data = self._title_analyser.return_dict(torrent.name)