Nextcloud upload: mapping Qnet station -> NC folder. Qnet baza ima FOLX SLO/ONE/ZWEI, Nextcloud pa FOLX SLOVENIJA/ONE DE/ZWEI MUSIC \u2014 STATION_TO_NEXTCLOUD_FOLDER dict normalizira pri uploadu. Re\u0161i HTTP 404 NotFound za FOLX SLO jobe (106 jobov).

This commit is contained in:
OpenClaw Agent 2026-05-03 12:24:35 +02:00
parent a960b7157f
commit 6a9e20da19

View File

@ -950,7 +950,8 @@ def process_job(job_id):
update_job(job_id, nextcloud_status="uploading", nextcloud_error=None) update_job(job_id, nextcloud_status="uploading", nextcloud_error=None)
download_name = build_download_filename(final_job) download_name = build_download_filename(final_job)
tv_station = final_job.get("tv_station", "FOLX SLOVENIJA") 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) 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) success, result = _nextcloud_upload(str(output_path), download_name, target_subdir=target_subdir)
if success: if success:
@ -2079,6 +2080,27 @@ NEXTCLOUD_USER = os.environ.get("NEXTCLOUD_USER", "")
NEXTCLOUD_PASS = os.environ.get("NEXTCLOUD_PASS", "") NEXTCLOUD_PASS = os.environ.get("NEXTCLOUD_PASS", "")
NEXTCLOUD_REELS_PATH = os.environ.get("NEXTCLOUD_REELS_PATH", "folxspeed/REELS") 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(): def _nextcloud_configured():
return bool(NEXTCLOUD_URL and NEXTCLOUD_USER and NEXTCLOUD_PASS) 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 # Lepo ime datoteke
download_name = build_download_filename(job) 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") 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) print(f"☁️ Uploading {output_path} → Nextcloud /{target_subdir}/{download_name}", flush=True)
success, result = _nextcloud_upload(output_path, download_name, target_subdir=target_subdir) success, result = _nextcloud_upload(output_path, download_name, target_subdir=target_subdir)