From d3984084584e4c757930cecdb74dac729f017f8e Mon Sep 17 00:00:00 2001 From: Vladimir Buzalka Date: Fri, 19 Jun 2026 05:31:31 +0200 Subject: [PATCH] notebook --- EUNI/plex_export.py | 17 +++++++++++++++-- EUNI/plex_meta.py | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/EUNI/plex_export.py b/EUNI/plex_export.py index 86e3997..d38dc47 100644 --- a/EUNI/plex_export.py +++ b/EUNI/plex_export.py @@ -210,6 +210,15 @@ def main(): dest = Path(args.dest) dest.mkdir(parents=True, exist_ok=True) 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 dl_bytes = 0 t0 = time.time() @@ -221,9 +230,12 @@ def main(): if dst.exists() and dst.stat().st_size == size: skipped += 1 continue + print(f"[{n}/{len(plan)}] ↓ {size/1024**2:.1f}MB {fn}", flush=True) try: 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() tmp = dst.with_suffix(".part") with open(tmp, "wb") as f: @@ -232,7 +244,8 @@ def main(): tmp.replace(dst) done += 1 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: failed += 1 msg = f"[{n}/{len(plan)}] FAIL {fn} :: {e}" diff --git a/EUNI/plex_meta.py b/EUNI/plex_meta.py index 9bca6f1..e8363f3 100644 --- a/EUNI/plex_meta.py +++ b/EUNI/plex_meta.py @@ -35,6 +35,7 @@ for _s in (sys.stdout, sys.stderr): DEF_PLEX = "http://192.168.1.76:32400" 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). # 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("--section", type=int, default=DEF_SECTION) 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", help="nevybirat nahled (jen metadata)") args = ap.parse_args()