This commit is contained in:
2026-06-19 05:31:31 +02:00
parent 92048d51f7
commit d398408458
2 changed files with 17 additions and 3 deletions
+15 -2
View File
@@ -210,6 +210,15 @@ def main():
dest = Path(args.dest) dest = Path(args.dest)
dest.mkdir(parents=True, exist_ok=True) dest.mkdir(parents=True, exist_ok=True)
log_path = dest / "_export_log.txt" log_path = dest / "_export_log.txt"
# preflight: dosahnu na filer?
try:
requests.get(args.filer, timeout=8)
print(f"Filer OK: {args.filer}\n", flush=True)
except Exception as e:
sys.exit(f"NEDOSTUPNY FILER {args.filer} :: {e}\n"
f"Zkontroluj sit / VPN na 192.168.1.50:8888 z tohoto stroje.")
done = skipped = failed = 0 done = skipped = failed = 0
dl_bytes = 0 dl_bytes = 0
t0 = time.time() t0 = time.time()
@@ -221,9 +230,12 @@ def main():
if dst.exists() and dst.stat().st_size == size: if dst.exists() and dst.stat().st_size == size:
skipped += 1 skipped += 1
continue continue
print(f"[{n}/{len(plan)}] ↓ {size/1024**2:.1f}MB {fn}", flush=True)
try: try:
url = filer_url(args.filer, path) url = filer_url(args.filer, path)
with requests.get(url, stream=True, timeout=300) as r: ts = time.time()
# timeout=(connect, read) -> zaseknute spojeni spadne rychle
with requests.get(url, stream=True, timeout=(15, 90)) as r:
r.raise_for_status() r.raise_for_status()
tmp = dst.with_suffix(".part") tmp = dst.with_suffix(".part")
with open(tmp, "wb") as f: with open(tmp, "wb") as f:
@@ -232,7 +244,8 @@ def main():
tmp.replace(dst) tmp.replace(dst)
done += 1 done += 1
dl_bytes += size dl_bytes += size
msg = f"[{n}/{len(plan)}] OK {size/1024**2:.1f}MB {fn}" sp = size / 1024**2 / max(time.time() - ts, 0.1)
msg = f"[{n}/{len(plan)}] OK {size/1024**2:.1f}MB ({sp:.1f} MB/s) {fn}"
except Exception as e: except Exception as e:
failed += 1 failed += 1
msg = f"[{n}/{len(plan)}] FAIL {fn} :: {e}" msg = f"[{n}/{len(plan)}] FAIL {fn} :: {e}"
+2 -1
View File
@@ -35,6 +35,7 @@ for _s in (sys.stdout, sys.stderr):
DEF_PLEX = "http://192.168.1.76:32400" DEF_PLEX = "http://192.168.1.76:32400"
DEF_SECTION = 23 # EUNI (Other Videos) DEF_SECTION = 23 # EUNI (Other Videos)
DEF_TOKEN = "Em6_tQ7DizF2s36-9_Jx" # natvrdo; lze prebit env PLEX_TOKEN nebo --token
# Mapovani profese kodu EUNI -> nazev (nezname kody se vynechaji). # Mapovani profese kodu EUNI -> nazev (nezname kody se vynechaji).
# Cely soucasny batch je profese 2 = Lékař. Dalsi profese doplnit az se dotahnou. # Cely soucasny batch je profese 2 = Lékař. Dalsi profese doplnit az se dotahnou.
@@ -162,7 +163,7 @@ def main():
ap.add_argument("--plex", default=DEF_PLEX) ap.add_argument("--plex", default=DEF_PLEX)
ap.add_argument("--section", type=int, default=DEF_SECTION) ap.add_argument("--section", type=int, default=DEF_SECTION)
ap.add_argument("--mongo", default=px.DEF_MONGO) ap.add_argument("--mongo", default=px.DEF_MONGO)
ap.add_argument("--token", default=os.environ.get("PLEX_TOKEN", "")) ap.add_argument("--token", default=os.environ.get("PLEX_TOKEN") or DEF_TOKEN)
ap.add_argument("--no-poster", action="store_true", ap.add_argument("--no-poster", action="store_true",
help="nevybirat nahled (jen metadata)") help="nevybirat nahled (jen metadata)")
args = ap.parse_args() args = ap.parse_args()