diff --git a/app/main.py b/app/main.py index ea6e6b7..3bf3ea8 100644 --- a/app/main.py +++ b/app/main.py @@ -768,6 +768,32 @@ def process_job(job_id): except Exception as e: print(f"⚠️ Edit precache failed: {e}", flush=True) + # Avto-upload v Nextcloud če flag set (npr. po Save/recut) + try: + final_job = load_job(job_id) + if final_job.get("auto_upload_to_nextcloud") and _nextcloud_configured(): + update_job(job_id, nextcloud_status="uploading", nextcloud_error=None) + download_name = build_download_filename(final_job) + tv_station = final_job.get("tv_station", "FOLX SLOVENIJA") + target_subdir = f"folxspeed/REELS/{tv_station}" + print(f"☁️ Avto-upload v Nextcloud: /{target_subdir}/{download_name}", flush=True) + success, result = _nextcloud_upload(str(output_path), download_name, target_subdir=target_subdir) + if success: + update_job( + job_id, + nextcloud_status="uploaded", + nextcloud_url=result, + nextcloud_error=None, + auto_upload_to_nextcloud=False, # disable da se ne ponovi + hidden_after_upload=True, # signal za UI da ga skrije + ) + print(f"☁️ Auto-upload OK: /{target_subdir}/{download_name}", flush=True) + else: + update_job(job_id, nextcloud_status="error", nextcloud_error=result) + print(f"⚠️ Auto-upload failed: {result}", flush=True) + except Exception as e: + print(f"⚠️ Auto-upload error: {e}", flush=True) + # Batch tracking — če je zadnji v batchu, pošlji summary _try_finalize_batch(job_id) else: @@ -1537,6 +1563,7 @@ class RecutRequest(BaseModel): end: float custom_segments: Optional[list] = None # [{start, end, text}] za override napisov no_subs: Optional[bool] = None + auto_upload: bool = True # po končanem recut avto-naloži v Nextcloud (default: da, ker user je že pregledal) # ─── Nextcloud upload ───────────────────────────────────────────── @@ -1689,6 +1716,7 @@ async def recut_job(job_id: str, payload: RecutRequest, user: str = Depends(chec status="queued", no_subs=no_subs, custom_clip=True, # flag da preskoči Soniox + Claude + auto_upload_to_nextcloud=payload.auto_upload, # avto-upload po končanem recut current_step="V vrsti za recut", error=None, chorus_error=None, diff --git a/templates/index.html b/templates/index.html index deb3b35..a6374a0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -900,14 +900,16 @@ if (!r.ok) return; const data = await r.json(); const list = $("#jobs-list"); - if (!data.jobs.length) { + // Filtriraj ven jobe ki so že naloženi in skriti + const visible = data.jobs.filter(j => !j.hidden_after_upload); + if (!visible.length) { list.innerHTML = '