diff --git a/local_podcast_generator.py b/local_podcast_generator.py index faa18af..3803eea 100644 --- a/local_podcast_generator.py +++ b/local_podcast_generator.py @@ -54,13 +54,17 @@ class LocalPodcastGenerator: album = str(audio.tags.get('TALB', [''])[0]) if audio.tags.get('TALB') else None # Cover-Art extrahieren (APIC = Attached Picture) - if 'APIC:' in audio.tags: - cover_data = audio.tags.get('APIC:').data - elif audio.tags.get('APIC'): - # Fallback für andere APIC-Varianten - apic_tags = [tag for tag in audio.tags if tag.startswith('APIC')] - if apic_tags: - cover_data = audio.tags.get(apic_tags[0]).data + # Versuche verschiedene APIC-Tag-Varianten + for key in audio.tags.keys(): + if key.startswith('APIC'): + try: + cover_data = audio.tags[key].data + if cover_data: + print(f" 🎨 Cover gefunden in Tag: {key}") + break + except Exception as tag_error: + print(f" ⚠️ Fehler beim Lesen von {key}: {tag_error}") + continue # Dauer in Sekunden if hasattr(audio, 'info') and audio.info.length: @@ -110,18 +114,16 @@ class LocalPodcastGenerator: # Erstelle Cover-Dateiname basierend auf MP3-Dateiname cover_filename = f"cover_{Path(metadata['filename']).stem}.jpg" - # Speichere Cover im httpdocs-Verzeichnis - if "../httpdocs" in self.audio_dir: - cover_path = Path("../httpdocs") / cover_filename - else: - cover_path = Path(cover_filename) + # Speichere Cover im _audio-Verzeichnis (neben den MP3-Dateien) + audio_path = Path(self.audio_dir) + cover_path = audio_path / cover_filename # Schreibe Cover-Daten in Datei with open(cover_path, 'wb') as f: f.write(metadata['cover_data']) - # Rückgabe der URL zum Cover - cover_url = f"{self.base_url}/{cover_filename}" + # Rückgabe der URL zum Cover (im _audio-Verzeichnis) + cover_url = f"{self.base_url}/_audio/{cover_filename}" print(f" 🖼️ Cover extrahiert: {cover_filename}") return cover_url