@@ 219,16 219,23 @@ def file_metadata(file_path: str) -> dict:
.split(", ")[1]
.split(" ")[0]
)
- data_dict.update(
- {
- "cover_art": "data:{m};base64,{b}".format(
- m=mimetype,
- b=codecs.encode(
- mp3.tags["APIC:{}".format(filename)].data, "base64"
- ).decode(),
- ).rstrip("\n")
- }
- )
+ try:
+ data_dict.update(
+ {
+ "cover_art": "data:{m};base64,{b}".format(
+ m=mimetype,
+ b=codecs.encode(
+ mp3.tags["APIC:{}".format(filename)].data,
+ "base64",
+ ).decode(),
+ ).rstrip("\n")
+ }
+ )
+ except KeyError:
+ wrn("Could not encode image to base64 for: " + file_path)
+ # There was some error getting the image in base64,
+ # so just forget about it.
+ pass
except MP3HeaderNotFoundError:
wrn("This file is not a valid mp3 file: " + file_path)