Praxis-Feedback-Runde: CIFS-Cap-Fix, TMDB v3-Keys, 4K-UHD-Typ, Vollautomatik, Job-Verwaltung, Worker-Namen
Ampel / ampel (push) Successful in 29s
Ampel / ampel (push) Successful in 29s
Zwei bewiesene Bug-Fixes:
- SMB-Mount 'Unable to apply new capability set': mount.cifs hebt
CAP_DAC_READ_SEARCH an, die in Dockers Default-Caps fehlt (auf der VM
reproduziert: Bounding-Set a82425fb ohne Bit 2; mit der Capability
verschwindet der Fehler). Fix: cap_add DAC_READ_SEARCH fuer den
api-Container.
- TMDB fiel still aus: Client konnte nur v4-Bearer-Tokens, der uebliche
32-Hex-v3-Key bekam 401 und die Suche lieferte nur OMDb. Jetzt beide
Key-Arten (ist_v4_token + api_key-Query-Param lt.
developer.themoviedb.org, mit Tests) — damit kommen auch die deutschen
Texte an (language=de-DE war ueberall schon gesetzt). Neu:
GET /metadata/status + 'Verbindung pruefen' in Einstellungen -> APIs
(Live-Check am Cache vorbei).
Features aus dem Commander-Feedback:
- 4K UHD als eigener Disc-Typ: classify >= 55 GiB (BD-66/BD-100; BD-50
bleibt bluray), beide detection.py + Tests, eigene Badge-Farbe in
Dashboard/Laufwerken, Prescan-Label '4K UHD'. UHD-Rip-Fehler 'Failed to
open disc' (Code 11) bekommt Klartext: LibreDrive-Firmware noetig.
- Vollautomatik (Setting autoRipStart): Disc erkannt -> Rip startet ohne
Popup in den Schnellwahl-Ordner (Serie->Serien, sonst Filme, CD->Musik).
- Job-Verwaltung: 'Neu komprimieren' nur noch mit can_retry (Rohdaten
liegen wirklich da), DELETE /jobs/{id} + 'Erledigte aufraeumen'
(Dateien bleiben immer), 'Alle herunterladen' im Job-Detail
(gestaffelte Einzel-Downloads statt Server-Zip von 40-GB-Dateien).
- Worker zuordenbar: WORKER_NAME-Env als stabiler Anzeigename (fixt auch
die Offline-Leichen nach Rebuilds), info.hostname/ip gemeldet,
Online-Abgleich ueber hostname, DELETE /workers/{name} + Papierkorb im
UI, Quelle-Anzeige an der Disc-Karte ('Quelle: TMDB - 99 % sicher').
- Ripping-Tab nach Medium gegliedert (Video/Audio-CD/Allgemein) +
Untertitel-Klartext (--all-audio/--all-subtitles bleiben komplett),
CD -> Musik-Vorauswahl im Ziel-Dialog, Ordner-Verwaltung beschriftet
und standardmaessig eingeklappt.
- Docs: SAVEPOINT v3.3, ROADMAP Etappe 14 + Ideen (nativer
Windows-Worker, deutsche OMDb-Texte via TMDB-Find), README.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+145
-3
@@ -91,11 +91,56 @@ async def _auto_prescan(pfad: str):
|
||||
+ (f" ({ergebnis.year})" if ergebnis.year else "")
|
||||
+ f" [{ergebnis.disc_type}, Confidence {ergebnis.confidence:.0%}] auf {pfad}",
|
||||
)
|
||||
await _auto_rip_wenn_aktiviert(pfad)
|
||||
except Exception as e:
|
||||
DISC_CACHE.pop(pfad, None)
|
||||
print(f"Auto-Pre-Scan {pfad}: {e}")
|
||||
|
||||
|
||||
async def _auto_rip_wenn_aktiviert(pfad: str):
|
||||
"""Vollautomatik (Setting autoRipStart): Disc erkannt → Rip startet sofort.
|
||||
|
||||
Commander-Wunsch 24.07.: wahlweise Popup ODER Automatik. Ziel-Ordner
|
||||
kommt aus den Schnellwahl-Einstellungen (Serie → seriesDir, sonst
|
||||
movieDir; CD → musicDir) — genau wie ein Klick im Dialog.
|
||||
"""
|
||||
einstellungen = await asyncio.to_thread(db.get_settings)
|
||||
if not einstellungen.get("autoRipStart"):
|
||||
return
|
||||
if await asyncio.to_thread(db.has_active_job, pfad):
|
||||
return
|
||||
disc = DISC_CACHE.get(pfad) or {}
|
||||
if disc.get("_laeuft"):
|
||||
return
|
||||
|
||||
basis = einstellungen.get("outputDir") or MEDIA_ROOT
|
||||
meta = disc.get("metadata") or {}
|
||||
if disc.get("disc_type") == "CD":
|
||||
unterordner = einstellungen.get("musicDir") or "music"
|
||||
elif meta.get("type") == "tv":
|
||||
unterordner = einstellungen.get("seriesDir") or "series"
|
||||
else:
|
||||
unterordner = einstellungen.get("movieDir") or "movies"
|
||||
ziel = os.path.normpath(os.path.join(basis, unterordner))
|
||||
if not ziel.startswith(MEDIA_ROOT):
|
||||
ziel = None
|
||||
|
||||
job_id = str(uuid.uuid4())
|
||||
meta_json = json.dumps({
|
||||
"year": disc.get("year"),
|
||||
"confidence": disc.get("confidence"),
|
||||
**meta,
|
||||
})
|
||||
await asyncio.to_thread(
|
||||
db.insert_job, job_id, pfad, None, disc.get("title"), ziel, meta_json
|
||||
)
|
||||
await asyncio.to_thread(
|
||||
db.add_log, "info", "api",
|
||||
f'Automatik: Rip für „{disc.get("title")}" gestartet ({pfad} → {ziel})',
|
||||
)
|
||||
start_rip(pfad, job_id, ziel)
|
||||
|
||||
|
||||
async def disc_watcher():
|
||||
"""Disc-Wache: pollt die Laufwerke, protokolliert Einwurf/Auswurf und
|
||||
stößt beim Einlegen automatisch den Pre-Scan an (Dashboard-Disc-Karte).
|
||||
@@ -178,6 +223,7 @@ class Job(BaseModel):
|
||||
progress: int = 0
|
||||
title: Optional[str] = None
|
||||
error: Optional[str] = None
|
||||
can_retry: bool = False # Rohdaten vorhanden → „Neu komprimieren" sinnvoll
|
||||
|
||||
class Device(BaseModel):
|
||||
id: str
|
||||
@@ -219,11 +265,52 @@ async def root():
|
||||
}
|
||||
|
||||
|
||||
def _kann_neu_komprimieren(job: dict, work_dir: str) -> bool:
|
||||
"""Nur wenn Rohdaten wirklich noch daliegen — der „Neu komprimieren"-Knopf
|
||||
an einem Job, der nie gerippt hat, war Unsinn (Befund 24.07.)."""
|
||||
if job.get("status") != "failed":
|
||||
return False
|
||||
if os.path.isdir(os.path.join("/app/temp/raw", job["id"])):
|
||||
return True
|
||||
return work_dir.startswith(MEDIA_ROOT) and os.path.isdir(os.path.join(work_dir, job["id"]))
|
||||
|
||||
|
||||
@app.get("/jobs", response_model=List[Job])
|
||||
async def get_jobs():
|
||||
"""Holt alle Jobs aus der Datenbank (neueste zuerst)."""
|
||||
zeilen = await asyncio.to_thread(db.list_jobs)
|
||||
return [_job_row_to_model(z) for z in zeilen]
|
||||
def sammle():
|
||||
work_dir = os.path.normpath((db.get_settings().get("workDir") or "").strip() or "/")
|
||||
modelle = []
|
||||
for z in db.list_jobs():
|
||||
modell = _job_row_to_model(z)
|
||||
modell.can_retry = _kann_neu_komprimieren(z, work_dir)
|
||||
modelle.append(modell)
|
||||
return modelle
|
||||
|
||||
return await asyncio.to_thread(sammle)
|
||||
|
||||
|
||||
@app.delete("/jobs/{job_id}")
|
||||
async def delete_job(job_id: str):
|
||||
"""Entfernt einen erledigten Job aus der Liste (Dateien bleiben liegen)."""
|
||||
job = await asyncio.to_thread(db.get_job, job_id)
|
||||
if not job:
|
||||
raise HTTPException(status_code=404, detail="Job nicht gefunden")
|
||||
if job["status"] not in ("completed", "failed"):
|
||||
raise HTTPException(status_code=409, detail="Job läuft noch — erst abbrechen")
|
||||
await asyncio.to_thread(db.delete_job, job_id)
|
||||
await asyncio.to_thread(db.add_log, "info", "api", f"Job {job_id} aus der Liste entfernt")
|
||||
return {"status": "deleted"}
|
||||
|
||||
|
||||
@app.delete("/jobs")
|
||||
async def delete_finished_jobs():
|
||||
"""Räumt ALLE erledigten Jobs (fertig + fehlgeschlagen) aus der Liste."""
|
||||
anzahl = await asyncio.to_thread(db.delete_finished_jobs)
|
||||
await asyncio.to_thread(
|
||||
db.add_log, "info", "api", f"Job-Liste aufgeräumt ({anzahl} erledigte Einträge entfernt)"
|
||||
)
|
||||
return {"deleted": anzahl}
|
||||
|
||||
|
||||
class JobCreateRequest(BaseModel):
|
||||
@@ -500,12 +587,67 @@ async def capabilities():
|
||||
except Exception:
|
||||
online_namen = set()
|
||||
for zeile in zeilen:
|
||||
zeile["online"] = zeile["name"] in online_namen
|
||||
# Celery-Ping meldet den HOSTNAME des Knotens — bei gesetztem
|
||||
# WORKER_NAME (Anzeigename) steckt der echte Hostname in info.
|
||||
hostname = (zeile.get("info") or {}).get("hostname") or zeile["name"]
|
||||
zeile["online"] = hostname in online_namen
|
||||
return zeilen
|
||||
|
||||
return {"workers": await asyncio.to_thread(sammle)}
|
||||
|
||||
|
||||
@app.delete("/workers/{name}")
|
||||
async def delete_worker(name: str):
|
||||
"""Verwaisten Worker-Eintrag entfernen (alte Container-IDs nach Rebuilds).
|
||||
|
||||
Ein AKTIVER Worker meldet sich binnen einer Minute einfach wieder an —
|
||||
löschen ist also immer gefahrlos."""
|
||||
await asyncio.to_thread(db.delete_worker, name)
|
||||
await asyncio.to_thread(db.add_log, "info", "api", f"Worker-Eintrag '{name}' entfernt")
|
||||
return {"status": "deleted"}
|
||||
|
||||
|
||||
@app.get("/metadata/status")
|
||||
async def metadata_status():
|
||||
"""Live-Prüfung der Metadaten-Quellen — beantwortet „funktioniert mein
|
||||
Key?" sofort statt durch stilles Wegfallen einer Quelle."""
|
||||
def pruefe():
|
||||
from clients.omdb import OMDB_BASE_URL
|
||||
from clients.tmdb import TMDB_BASE_URL
|
||||
|
||||
status = {}
|
||||
prescan = PreScan()
|
||||
# Bewusst am Cache VORBEI — ein alter Treffer soll keinen kaputten
|
||||
# Key als "ok" tarnen. /configuration ist der kleinste Auth-Aufruf.
|
||||
if not prescan.tmdb.api_key:
|
||||
status["tmdb"] = "kein_key"
|
||||
else:
|
||||
try:
|
||||
antwort = prescan.tmdb.session.get(
|
||||
f"{TMDB_BASE_URL}/configuration",
|
||||
params=prescan.tmdb._key_params, timeout=10,
|
||||
)
|
||||
status["tmdb"] = "ok" if antwort.status_code == 200 else "fehler"
|
||||
except Exception:
|
||||
status["tmdb"] = "fehler"
|
||||
if not prescan.omdb.api_key:
|
||||
status["omdb"] = "kein_key"
|
||||
else:
|
||||
try:
|
||||
antwort = prescan.omdb.session.get(
|
||||
OMDB_BASE_URL,
|
||||
params={"apikey": prescan.omdb.api_key, "t": "Inception"},
|
||||
timeout=10,
|
||||
).json()
|
||||
status["omdb"] = "ok" if antwort.get("Response") == "True" else "fehler"
|
||||
except Exception:
|
||||
status["omdb"] = "fehler"
|
||||
status["jikan"] = "ok" # keyless — fällt nur bei Netzproblemen aus
|
||||
return status
|
||||
|
||||
return await asyncio.to_thread(pruefe)
|
||||
|
||||
|
||||
class MountRequest(BaseModel):
|
||||
name: str
|
||||
type: str # nfs | cifs
|
||||
|
||||
Reference in New Issue
Block a user