mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-20 23:20:32 +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:
parent
4523a12708
commit
878fd85c63
16
cps/audio.py
16
cps/audio.py
@ -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"]:
|
elif original_file_extension in [".ogg", ".flac"]:
|
||||||
title = audio_file.tags.get('TITLE')[0] if "TITLE" in audio_file else None
|
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
|
author = audio_file.tags.get('ARTIST')[0] if "ARTIST" in audio_file else None
|
||||||
comments = None # audio_file.tags.get('COMM', None)
|
comments = audio_file.tags.get('COMMENTS')[0] if "COMMENTS" in audio_file else None
|
||||||
tags = ""
|
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 = 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
|
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
|
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')
|
cover_data = audio_file.tags.get('METADATA_BLOCK_PICTURE')
|
||||||
if cover_data:
|
if cover_data:
|
||||||
tmp_cover_name = os.path.join(os.path.dirname(tmp_file_path), 'cover.jpg')
|
tmp_cover_name = os.path.join(os.path.dirname(tmp_file_path), 'cover.jpg')
|
||||||
with open(tmp_cover_name, "wb") as cover_file:
|
cover_info = mutagen.flac.Picture(base64.b64decode(cover_data[0]))
|
||||||
cover_file.write(mutagen.flac.Picture(base64.b64decode(cover_data[0])).data)
|
cover.cover_processing(tmp_file_path, cover_info.data, "." + cover_info.mime[-3:])
|
||||||
if hasattr(audio_file, "pictures"):
|
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')
|
tmp_cover_name = os.path.join(os.path.dirname(tmp_file_path), 'cover.jpg')
|
||||||
with open(tmp_cover_name, "wb") as cover_file:
|
cover.cover_processing(tmp_file_path, cover_info.data, "." + cover_info.mime[-3:])
|
||||||
cover_file.write(audio_file.pictures[0].data)
|
|
||||||
elif original_file_extension in [".aac"]:
|
elif original_file_extension in [".aac"]:
|
||||||
title = audio_file.tags.get('Title').value if "title" in audio_file else None
|
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
|
author = audio_file.tags.get('Artist').value if "artist" in audio_file else None
|
||||||
|
@ -1020,7 +1020,7 @@ def edit_book_series_index(series_index, book):
|
|||||||
modify_date = False
|
modify_date = False
|
||||||
series_index = series_index or '1'
|
series_index = series_index or '1'
|
||||||
if not series_index.replace('.', '', 1).isdigit():
|
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
|
return False
|
||||||
if str(book.series_index) != series_index:
|
if str(book.series_index) != series_index:
|
||||||
book.series_index = series_index
|
book.series_index = series_index
|
||||||
|
Loading…
Reference in New Issue
Block a user