diff --git a/src/musiksammlung/cli.py b/src/musiksammlung/cli.py index 5dba9c4..bcbe1b7 100644 --- a/src/musiksammlung/cli.py +++ b/src/musiksammlung/cli.py @@ -6,6 +6,7 @@ import json import logging from pathlib import Path +import httpx import typer from mutagen import File as MutagenFile @@ -46,7 +47,18 @@ def _scan_to_album( """Gemeinsame Scan-Logik: Barcode, Text-Datei, Vision-LLM oder OCR+LLM.""" if barcode: typer.echo(f"MusicBrainz-Suche nach Barcode {barcode}...") - return lookup_by_barcode(barcode) + try: + return lookup_by_barcode(barcode) + except ValueError as e: + typer.echo(f"Fehler: {e}", err=True) + typer.echo( + "Tipp: Barcode prüfen oder Metadaten per --from-text / --vision ermitteln.", + err=True, + ) + raise typer.Exit(1) + except httpx.HTTPError as e: + typer.echo(f"Netzwerkfehler bei MusicBrainz-Abfrage: {e}", err=True) + raise typer.Exit(1) elif from_text: text = from_text.read_text(encoding="utf-8") typer.echo(f"Text-Datei geladen ({len(text)} Zeichen). LLM-Parsing...") diff --git a/tests/test_ripper.py b/tests/test_ripper.py index dfd2b15..3666d09 100644 --- a/tests/test_ripper.py +++ b/tests/test_ripper.py @@ -1,7 +1,7 @@ """Tests für den CD-Ripper.""" from pathlib import Path -from unittest.mock import MagicMock, call, patch +from unittest.mock import MagicMock, patch from musiksammlung.config import AudioFormat from musiksammlung.models import Album, Disc, Track