Etappe 2: Ripping-Pipeline — Erste Implementierung
- 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
This commit is contained in:
+50
-10
@@ -1,15 +1,55 @@
|
||||
import os
|
||||
import subprocess
|
||||
from celery_app import celery_app
|
||||
from ripping import rip_dvd, rip_bluray
|
||||
|
||||
|
||||
@celery_app.task(bind=True, name="worker.tasks.detect_disc")
|
||||
def detect_disc(self, device_path: str, disc_type: str):
|
||||
"""Dummy-Disk-Erkennungstask."""
|
||||
print(f"Disc erkannt: {disc_type}, Device: {device_path}")
|
||||
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"
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"message": f"Disc erkannt: {disc_type}",
|
||||
"device_path": device_path,
|
||||
"disc_type": disc_type
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user