This commit is contained in:
2026-04-16 12:56:33 +02:00
parent a1a06aa547
commit 4683d6f853
6 changed files with 183 additions and 20 deletions
+15 -10
View File
@@ -160,16 +160,21 @@ def parse_page(html):
# DOWNLOAD .TORRENT FILE
# ============================================================
def download_torrent(session, url):
try:
r = session.get(url, timeout=15)
r.raise_for_status()
if len(r.content) < 20:
return None
return r.content
except Exception as e:
print(f" ⚠️ Stažení selhalo: {e}")
return None
def download_torrent(session, url, retries=10, retry_delay=10):
for attempt in range(1, retries + 1):
try:
r = session.get(url, timeout=15)
r.raise_for_status()
if len(r.content) < 20:
raise ValueError(f"Odpověď příliš krátká ({len(r.content)} B)")
return r.content
except Exception as e:
if attempt < retries:
print(f" ⚠️ Pokus {attempt}/{retries} selhal: {e} — čekám {retry_delay}s")
time.sleep(retry_delay)
else:
print(f" ✖ Všechny pokusy ({retries}) selhaly: {e}")
return None
# ============================================================