1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-18 22:20:30 +00:00

Fixes for audio metadata extraction of oggvorbis and flac files (handle more than one cover and png covers as well)

This commit is contained in:
Ozzie Isaacs 2024-08-11 11:49:43 +02:00
parent 4523a12708
commit 878fd85c63
2 changed files with 11 additions and 7 deletions

View File

@ -60,8 +60,8 @@ def get_audio_file_info(tmp_file_path, original_file_extension, original_file_na
elif original_file_extension in [".ogg", ".flac"]:
title = audio_file.tags.get('TITLE')[0] if "TITLE" in audio_file else None
author = audio_file.tags.get('ARTIST')[0] if "ARTIST" in audio_file else None
comments = None # audio_file.tags.get('COMM', None)
tags = ""
comments = audio_file.tags.get('COMMENTS')[0] if "COMMENTS" in audio_file else None
tags = audio_file.tags.get('GENRE')[0] if "GENRE" in audio_file else None # Genre
series = audio_file.tags.get('ALBUM')[0] if "ALBUM" in audio_file else None
series_id = audio_file.tags.get('TRACKNUMBER')[0] if "TRACKNUMBER" in audio_file else None
publisher = audio_file.tags.get('LABEL')[0] if "LABEL" in audio_file else None
@ -69,12 +69,16 @@ def get_audio_file_info(tmp_file_path, original_file_extension, original_file_na
cover_data = audio_file.tags.get('METADATA_BLOCK_PICTURE')
if cover_data:
tmp_cover_name = os.path.join(os.path.dirname(tmp_file_path), 'cover.jpg')
with open(tmp_cover_name, "wb") as cover_file:
cover_file.write(mutagen.flac.Picture(base64.b64decode(cover_data[0])).data)
cover_info = mutagen.flac.Picture(base64.b64decode(cover_data[0]))
cover.cover_processing(tmp_file_path, cover_info.data, "." + cover_info.mime[-3:])
if hasattr(audio_file, "pictures"):
cover_info = audio_file.pictures[0]
for dat in audio_file.pictures:
if dat.type == mutagen.id3.PictureType.COVER_FRONT:
cover_info = dat
break
tmp_cover_name = os.path.join(os.path.dirname(tmp_file_path), 'cover.jpg')
with open(tmp_cover_name, "wb") as cover_file:
cover_file.write(audio_file.pictures[0].data)
cover.cover_processing(tmp_file_path, cover_info.data, "." + cover_info.mime[-3:])
elif original_file_extension in [".aac"]:
title = audio_file.tags.get('Title').value if "title" in audio_file else None
author = audio_file.tags.get('Artist').value if "artist" in audio_file else None

View File

@ -1020,7 +1020,7 @@ def edit_book_series_index(series_index, book):
modify_date = False
series_index = series_index or '1'
if not series_index.replace('.', '', 1).isdigit():
flash(_("%(seriesindex)s is not a valid number, skipping", seriesindex=series_index), category="warning")
flash(_("Seriesindex: %(seriesindex)s is not a valid number, skipping", seriesindex=series_index), category="warning")
return False
if str(book.series_index) != series_index:
book.series_index = series_index