diff --git a/app/main.py b/app/main.py index 9013ddb..f21e995 100644 --- a/app/main.py +++ b/app/main.py @@ -950,7 +950,8 @@ def process_job(job_id): 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}" + nc_folder = _nextcloud_folder_for_station(tv_station) + target_subdir = f"folxspeed/REELS/{nc_folder}" 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: @@ -2079,6 +2080,27 @@ NEXTCLOUD_USER = os.environ.get("NEXTCLOUD_USER", "") NEXTCLOUD_PASS = os.environ.get("NEXTCLOUD_PASS", "") NEXTCLOUD_REELS_PATH = os.environ.get("NEXTCLOUD_REELS_PATH", "folxspeed/REELS") +# Mapping: Qnet baza station naziv → Nextcloud folder naziv. +# Qnet Songs.txt ima krajsa imena ("FOLX SLO", "ONE", "ZWEI"), Nextcloud +# pa daljse ("FOLX SLOVENIJA", "ONE DE", "ZWEI MUSIC"). Pri uploadu mapiramo. +STATION_TO_NEXTCLOUD_FOLDER = { + "FOLX SLO": "FOLX SLOVENIJA", + "FOLX SLOVENIJA": "FOLX SLOVENIJA", + "FOLX DE": "FOLX DE", + "ONE": "ONE DE", + "ONE DE": "ONE DE", + "ZWEI": "ZWEI MUSIC", + "ZWEI MUSIC": "ZWEI MUSIC", + "ADRIA": "ADRIA", +} + + +def _nextcloud_folder_for_station(tv_station: str) -> str: + """Vrne pravi Nextcloud folder za dano tv_station (z mapping fallback).""" + if not tv_station: + return "FOLX SLOVENIJA" + return STATION_TO_NEXTCLOUD_FOLDER.get(tv_station.strip(), tv_station.strip()) + def _nextcloud_configured(): return bool(NEXTCLOUD_URL and NEXTCLOUD_USER and NEXTCLOUD_PASS) @@ -2151,9 +2173,10 @@ async def upload_nextcloud(job_id: str, user: str = Depends(check_auth)): # Lepo ime datoteke download_name = build_download_filename(job) - # TV postaja določa target mapo + # TV postaja določa target mapo (mapping Qnet -> Nextcloud folder) tv_station = job.get("tv_station", "FOLX SLOVENIJA") - target_subdir = f"folxspeed/REELS/{tv_station}" + nc_folder = _nextcloud_folder_for_station(tv_station) + target_subdir = f"folxspeed/REELS/{nc_folder}" print(f"☁️ Uploading {output_path} → Nextcloud /{target_subdir}/{download_name}", flush=True) success, result = _nextcloud_upload(output_path, download_name, target_subdir=target_subdir)