From 1621e378766903e4da8ed07eb9e6573905ff4511 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Sun, 6 Jul 2025 11:11:43 +0200 Subject: [PATCH] Verbessere die Extraktion von Kommentar-Tags in MP3-Metadaten mit erweiterten Fehlerbehandlungen und verbesserten Ausgaben. --- local_podcast_generator.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/local_podcast_generator.py b/local_podcast_generator.py index b1cf833..9b0a947 100644 --- a/local_podcast_generator.py +++ b/local_podcast_generator.py @@ -89,15 +89,25 @@ class LocalPodcastGenerator: album = str(audio.tags.get('TALB', [''])[0]) if audio.tags.get('TALB') else None # Comment-Tag extrahieren (COMM = Comment) - if audio.tags.get('COMM::eng'): - comment = str(audio.tags.get('COMM::eng', [''])[0]) - elif audio.tags.get('COMM'): - # Fallback für allgemeine COMM-Tags - comment_tags = audio.tags.getall('COMM') - if comment_tags: - comment = str(comment_tags[0]) + try: + # Versuche verschiedene Comment-Tag-Formate + if 'COMM::eng' in audio.tags: + comment = str(audio.tags['COMM::eng']) + elif 'COMM::' in str(audio.tags.keys()): + # Suche nach COMM-Tags mit beliebiger Sprache + for key in audio.tags.keys(): + if key.startswith('COMM::'): + comment = str(audio.tags[key]) + break + else: + # Versuche allgemeine COMM-Tags + comm_tags = audio.tags.getall('COMM') + if comm_tags: + comment = str(comm_tags[0]) + except Exception as comm_error: + print(f" ⚠️ Fehler beim Lesen des Comment-Tags: {comm_error}") - if comment: + if comment and comment.strip(): print(f" 💬 Comment gefunden: {comment[:50]}...") # Cover-Art extrahieren (APIC = Attached Picture) @@ -446,6 +456,9 @@ Ich spezialisiere mich auf House Music, die mehr als nur Beats bietet – sie er # Füge Comment hinzu falls vorhanden if metadata['comment'] and metadata['comment'].strip(): description_text += f"\n\n{metadata['comment']}" + print(f" 📝 Beschreibung erweitert mit Comment ({len(metadata['comment'])} Zeichen)") + else: + print(f" 📝 Standard-Beschreibung verwendet (kein Comment)") item_description.text = description_text