mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-29 18:51:24 +01:00
Compare commits
No commits in common. "428277de52e6130ec10387a3e79ddb7e76f014c5" and "83d4013ccb37c36790e6ce4eeed8b5598e84f16e" have entirely different histories.
428277de52
...
83d4013ccb
|
@ -96,10 +96,12 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||||
try:
|
try:
|
||||||
self._report_run('mutagen', filename)
|
self._report_run('mutagen', filename)
|
||||||
audio = mutagen.id3.ID3(filename)
|
audio = mutagen.id3.ID3(filename)
|
||||||
|
if 'APIC' in audio:
|
||||||
|
del audio['APIC']
|
||||||
with open(thumbnail_filename, 'rb') as thumbfile:
|
with open(thumbnail_filename, 'rb') as thumbfile:
|
||||||
audio['APIC'] = mutagen.id3.APIC(
|
audio['APIC'] = mutagen.id3.APIC(
|
||||||
encoding=mutagen.id3.Encoding.UTF8, mime=f'image/{thumbnail_ext}',
|
encoding=mutagen.id3.Encoding.UTF8, mime='image/%s' % thumbnail_ext, type=3,
|
||||||
type=mutagen.id3.PictureType.COVER_FRONT, desc='Cover (front)', data=thumbfile.read())
|
desc=u'Cover (front)', data=thumbfile.read())
|
||||||
audio.save()
|
audio.save()
|
||||||
temp_filename = filename # Mutagen saves to the original file
|
temp_filename = filename # Mutagen saves to the original file
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
|
@ -674,15 +674,17 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
if len(sub_dict) > 1:
|
if len(sub_dict) > 1:
|
||||||
self.report_warning('More than one subtitle file found. Your media player will likely be unable to display all of them.')
|
self.report_warning('More than one subtitle file found. Your media player will likely be unable to display all of them.')
|
||||||
|
|
||||||
if not all(sub['ext'] == 'lrc' for sub in sub_dict.values()):
|
if sub_dict[list(sub_dict.keys())[0]]['ext'] != 'lrc':
|
||||||
raise PostProcessingError('LRC subtitles required. Use "--convert-subs lrc" to convert')
|
raise PostProcessingError('LRC subtitles required. Use "--convert-subs lrc" to convert')
|
||||||
|
|
||||||
lyrics_list = [sub['data'] for sub in sub_dict.values()]
|
lyrics_list = []
|
||||||
|
for lyrics in sub_dict.keys():
|
||||||
|
lyrics_list.append(sub_dict[lyrics]['data'])
|
||||||
if audio_file.endswith('.mp3'):
|
if audio_file.endswith('.mp3'):
|
||||||
audio = mutagen.id3.ID3(audio_file)
|
|
||||||
for lyrics in lyrics_list:
|
for lyrics in lyrics_list:
|
||||||
audio.add(mutagen.id3.USLT(encoding=mutagen.id3.Encoding.UTF8, lang='und', text=lyrics))
|
audio = mutagen.id3.ID3(audio_file)
|
||||||
audio.save()
|
audio.add(mutagen.id3.USLT(encoding=3, lang='und', desc='', text=lyrics))
|
||||||
|
audio.save()
|
||||||
else:
|
else:
|
||||||
metadata = mutagen.File(audio_file)
|
metadata = mutagen.File(audio_file)
|
||||||
metadata['©lyr' if audio_file.endswith('.m4a') else 'lyrics'] = lyrics_list
|
metadata['©lyr' if audio_file.endswith('.m4a') else 'lyrics'] = lyrics_list
|
||||||
|
|
Loading…
Reference in New Issue
Block a user