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,17 +60,18 @@ def extract_metadata_and_thumbnail(file_path: str, thumb_resolution: tuple):
sound_length = round(easyid3.info.length, 2)
bitrate = int((easyid3.info.bitrate or 0) / 1000)
sample_rate = int(easyid3.info.sample_rate / 1000)
apic = id3.getall("APIC")
thumb_image_data = apic[0].data if apic else None
if thumb_image_data:
pil_image = Image.open(io.BytesIO(thumb_image_data)).convert("RGBA")
pil_image = pil_image.resize(thumb_resolution)
thumb_texture = arcade.Texture(pil_image)
except ID3NoHeaderError:
pass
apic = id3.getall("APIC")
thumb_image_data = apic[0].data if apic else None
if thumb_image_data:
pil_image = Image.open(io.BytesIO(thumb_image_data)).convert("RGBA")
pil_image = pil_image.resize(thumb_resolution)
thumb_texture = arcade.Texture(pil_image)
except Exception as 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,
}
def adjust_volume(input_path, volume):
audio = AudioSegment.from_file(input_path)
change = volume - audio.dBFS