mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-02 06:23:47 +08:00
Add filter switch
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user