fix(xtapes): ponawianie listy REST przy chwilowym bledzie proxy
Some checks are pending
Backend tests / test (push) Waiting to run
Some checks are pending
Backend tests / test (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b3938abf06
commit
34138ff82f
1 changed files with 15 additions and 5 deletions
|
|
@ -27,6 +27,7 @@ import html as html_mod
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
@ -130,11 +131,20 @@ class XtapesConnector(BaseMovieConnector):
|
||||||
# Tylko nowsze od ostatniego udanego przebiegu: strona filmu idzie przez proxy
|
# 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.
|
# (~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')}"
|
url += f"&after={since.strftime('%Y-%m-%dT%H:%M:%S')}"
|
||||||
try:
|
posts = None
|
||||||
posts = json.loads(self._get(url).text)
|
for attempt in range(3):
|
||||||
except Exception as e:
|
try:
|
||||||
# Za ostatnia strona WP oddaje 400 (rest_post_invalid_page_number).
|
posts = json.loads(self._get(url).text)
|
||||||
log.info("%s REST page=%d: %s", self.name, page, e)
|
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
|
return
|
||||||
if not isinstance(posts, list) or not posts:
|
if not isinstance(posts, list) or not posts:
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue