fix exception if there is no id3 metadata

This commit is contained in:
csd4ni3l
2025-07-21 18:08:37 +02:00
parent 1325f9546f
commit 3c938371c3

View File

@@ -60,8 +60,6 @@ def extract_metadata_and_thumbnail(file_path: str, thumb_resolution: tuple):
sound_length = round(easyid3.info.length, 2) sound_length = round(easyid3.info.length, 2)
bitrate = int((easyid3.info.bitrate or 0) / 1000) bitrate = int((easyid3.info.bitrate or 0) / 1000)
sample_rate = int(easyid3.info.sample_rate / 1000) sample_rate = int(easyid3.info.sample_rate / 1000)
except ID3NoHeaderError:
pass
apic = id3.getall("APIC") apic = id3.getall("APIC")
thumb_image_data = apic[0].data if apic else None thumb_image_data = apic[0].data if apic else None
@@ -71,6 +69,9 @@ def extract_metadata_and_thumbnail(file_path: str, thumb_resolution: tuple):
pil_image = pil_image.resize(thumb_resolution) pil_image = pil_image.resize(thumb_resolution)
thumb_texture = arcade.Texture(pil_image) thumb_texture = arcade.Texture(pil_image)
except ID3NoHeaderError:
pass
except Exception as e: except Exception as e:
logging.debug(f"[Metadata/Thumbnail Error] {file_path}: {e}") logging.debug(f"[Metadata/Thumbnail Error] {file_path}: {e}")
@@ -104,7 +105,6 @@ def extract_metadata_and_thumbnail(file_path: str, thumb_resolution: tuple):
"thumbnail": thumb_texture, "thumbnail": thumb_texture,
} }
def adjust_volume(input_path, volume): def adjust_volume(input_path, volume):
audio = AudioSegment.from_file(input_path) audio = AudioSegment.from_file(input_path)
change = volume - audio.dBFS change = volume - audio.dBFS