From a37d3d28c89062fe18b40e451f86319ae404541a Mon Sep 17 00:00:00 2001 From: Tohrusky <65994850+Tohrusky@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:58:23 +0000 Subject: [PATCH] fix: parse_nyaa func raise NetError --- animepipeline/loop.py | 6 +++++- animepipeline/rss/nyaa.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/animepipeline/loop.py b/animepipeline/loop.py index 41e39e4..303b637 100644 --- a/animepipeline/loop.py +++ b/animepipeline/loop.py @@ -102,7 +102,11 @@ async def start(self) -> None: # refresh rss config self.rss_config.refresh_config() for cfg in self.rss_config.nyaa: - torrent_info_list = parse_nyaa(cfg) + try: + torrent_info_list = parse_nyaa(cfg) + except Exception as e: + logger.error(f"Failed to parse nyaa for {cfg.name}: {e}") + continue for torrent_info in torrent_info_list: task_info = build_task_info( diff --git a/animepipeline/rss/nyaa.py b/animepipeline/rss/nyaa.py index ead0f72..7668ccf 100644 --- a/animepipeline/rss/nyaa.py +++ b/animepipeline/rss/nyaa.py @@ -5,13 +5,13 @@ import feedparser import httpx from loguru import logger -from tenacity import retry, stop_after_attempt, stop_after_delay, wait_random +from tenacity import retry, stop_after_attempt, wait_random from animepipeline.config import NyaaConfig from animepipeline.rss.type import TorrentInfo -@retry(wait=wait_random(min=3, max=5), stop=stop_after_delay(10) | stop_after_attempt(30)) +@retry(wait=wait_random(min=3, max=15), stop=stop_after_attempt(10)) def parse_nyaa(cfg: NyaaConfig) -> List[TorrentInfo]: rss_content = httpx.get(cfg.link).text