From 34138ff82fdc1f2fc147c2332ee35f10fbcc17db Mon Sep 17 00:00:00 2001 From: goon-foss Date: Thu, 15 Oct 2026 21:22:39 +0200 Subject: [PATCH] fix(xtapes): ponawianie listy REST przy chwilowym bledzie proxy Co-Authored-By: Claude Opus 5.5 --- app/connectors/xtapes.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/connectors/xtapes.py b/app/connectors/xtapes.py index 0ca0241..8021512 100644 --- a/app/connectors/xtapes.py +++ b/app/connectors/xtapes.py @@ -27,6 +27,7 @@ import html as html_mod import json import logging import re +import time from collections.abc import Iterator from datetime import datetime from urllib.parse import urlparse @@ -130,11 +131,20 @@ class XtapesConnector(BaseMovieConnector): # Tylko nowsze od ostatniego udanego przebiegu: strona filmu idzie przez proxy # (~9 s), a 3 pelne strony REST to 90 filmow, ponad limit 6 min na konektor. url += f"&after={since.strftime('%Y-%m-%dT%H:%M:%S')}" - try: - posts = json.loads(self._get(url).text) - except Exception as e: - # Za ostatnia strona WP oddaje 400 (rest_post_invalid_page_number). - log.info("%s REST page=%d: %s", self.name, page, e) + posts = None + for attempt in range(3): + try: + posts = json.loads(self._get(url).text) + break + except Exception as e: + # Za ostatnia strona WP oddaje 400 (rest_post_invalid_page_number), to koniec. + # Inne bledy (proxy, Cloudflare) bywaja chwilowe: pierwszy pelny przebieg + # 2026-10-15 skonczyl sie "sukcesem" z zerem filmow po jednym takim bledzie. + if "400 for" in str(e): + return + log.warning("%s REST page=%d proba %d: %s", self.name, page, attempt + 1, e) + time.sleep(3) + if posts is None: return if not isinstance(posts, list) or not posts: return