downloads: item 05 EN (Abt Daimon 2005/2017) + item 24 (Franz EN 1974 + RU Касталия 2018 djvu); items 03 big facsimiles + 05 RU + 11 RU in background queue
This commit is contained in:
parent
15944bf1cc
commit
40f174db76
1 changed files with 9 additions and 2 deletions
|
|
@ -91,6 +91,8 @@ def sniff(data: bytes) -> str:
|
|||
return "epub/zip"
|
||||
if data[:8] == b"\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1":
|
||||
return "doc/ole"
|
||||
if data[:8] in (b"AT&TFORM", b"AT&ToC\01", b"AT&ToC\02"):
|
||||
return "djvu"
|
||||
if b"<html" in data[:2000].lower():
|
||||
return "HTML-ERROR"
|
||||
return "unknown"
|
||||
|
|
@ -123,8 +125,13 @@ def download(f_id, out_dir, name, tries=8):
|
|||
continue
|
||||
url = m.group(1)
|
||||
tmp = out + ".part"
|
||||
rc = curl(url, out=tmp, referer=f"{BASE}/ads.php?md5={md5}", binary=True,
|
||||
timeout=900, extra=["-C", "-"])
|
||||
try:
|
||||
rc = curl(url, out=tmp, referer=f"{BASE}/ads.php?md5={md5}", binary=True,
|
||||
timeout=900, extra=["-C", "-"])
|
||||
except RuntimeError as e:
|
||||
print(f" try {t}: fetch error ({e}) — back off")
|
||||
time.sleep(45)
|
||||
continue
|
||||
data = open(tmp, "rb").read()
|
||||
kind = sniff(data)
|
||||
ok_size = (size == 0) or (len(data) == size)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue