Add filter switch

This commit is contained in:
EstrellaXD
2023-04-25 21:05:13 +08:00
parent f1204fab47
commit bdb3126d8e
3 changed files with 8 additions and 5 deletions

View File

@@ -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):

View File

@@ -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

View File

@@ -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)