fix: collector season limit. Fix #470

This commit is contained in:
EstrellaXD
2023-09-25 19:17:31 +08:00
parent a5f9f858bc
commit ba1674c6bf
3 changed files with 5 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ logger = logging.getLogger(__name__)
class SeasonCollector(DownloadClient):
def collect_season(self, bangumi: Bangumi, link: str = None, limit: int = 50):
def collect_season(self, bangumi: Bangumi, link: str = None, limit: int = None):
logger.info(
f"Start collecting {bangumi.official_title} Season {bangumi.season}..."
)

View File

@@ -30,8 +30,9 @@ class RequestContent(RequestURL):
torrents.append(
Torrent(name=_title, url=torrent_url, homepage=homepage)
)
if len(torrents) >= limit:
break
if isinstance(limit, int):
if len(torrents) >= limit:
break
return torrents
else:
logger.warning(f"[Network] Failed to get torrents: {_url}")

View File

@@ -44,7 +44,7 @@ class SearchTorrent(RequestContent, RSSAnalyser):
url = search_url(site, keywords)
return url
def search_season(self, data: Bangumi, site: str = "mikan", limit: int = 5) -> list[Torrent]:
def search_season(self, data: Bangumi, site: str = "mikan", limit: int = None) -> list[Torrent]:
rss_item = self.special_url(data, site)
torrents = self.search_torrents(rss_item, limit=limit)
return [torrent for torrent in torrents if data.title_raw in torrent.name]