9e73d065f9
- DockerfileWorker: abcde, flac, ffmpeg, handbrake-cli installiert - ripping.py: Ripping-Module für DVD/Blu-ray mit HandBrake - tasks.py: Disc-Typ-Erkennung + passendes Ripping-Modul - docker-compose.yml: Output-Verzeichnis /output hinzugefügt - output/ Verzeichnis erstellt WIP: CD-Ripping mit abcde noch nicht implementiert
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
import os
|
|
import subprocess
|
|
from celery_app import celery_app
|
|
from ripping import rip_dvd, rip_bluray
|
|
|
|
|
|
def detect_disc_type(device_path: str) -> str:
|
|
"""Erkennt den Disc-Typ anhand des Gerätepfads."""
|
|
try:
|
|
result = subprocess.run(
|
|
["file", "-L", device_path],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=10
|
|
)
|
|
|
|
output = result.stdout.lower()
|
|
|
|
if "dvd" in output or "video_ts" in output:
|
|
return "dvd"
|
|
elif "bluray" in output or "bdmv" in output:
|
|
return "bluray"
|
|
elif "audio" in output or "cda" in output:
|
|
return "cd"
|
|
else:
|
|
return "unknown"
|
|
|
|
except Exception:
|
|
return "unknown"
|
|
|
|
|
|
@celery_app.task(bind=True, name="worker.tasks.rip_disc")
|
|
def rip_disc(self, device_path: str, disc_id: str = None):
|
|
"""Rippt eine Disc basierend auf ihrem Typ."""
|
|
disc_type = detect_disc_type(device_path)
|
|
|
|
if not disc_id:
|
|
disc_id = device_path.replace("/", "_")
|
|
|
|
if disc_type == "cd":
|
|
return {
|
|
"status": "not_implemented",
|
|
"message": "CD-Ripping mit abcde noch nicht implementiert",
|
|
"disc_type": disc_type
|
|
}
|
|
elif disc_type == "dvd":
|
|
return rip_dvd(device_path, disc_id)
|
|
elif disc_type == "bluray":
|
|
return rip_bluray(device_path, disc_id)
|
|
else:
|
|
return {
|
|
"status": "error",
|
|
"message": f"Unbekannter Disc-Typ: {disc_type}",
|
|
"disc_type": disc_type
|
|
}
|