1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-10 15:28:33 +00:00

Fix encoding issues in embedthumbnail.py and embed_lyrics()

This commit is contained in:
Rohit 2023-12-29 22:11:18 +05:30
parent 51af60e6d7
commit 823543c2a4
2 changed files with 4 additions and 2 deletions

View File

@ -100,7 +100,7 @@ def run(self, info):
del audio['APIC']
with open(thumbnail_filename, 'rb') as thumbfile:
audio['APIC'] = mutagen.id3.APIC(
encoding=3, mime='image/%s' % thumbnail_ext, type=3,
encoding=mutagen.id3.Encoding.UTF8, mime='image/%s' % thumbnail_ext, type=3,
desc=u'Cover (front)', data=thumbfile.read())
audio.save()
temp_filename = filename # Mutagen saves to the original file

View File

@ -672,6 +672,8 @@ def run(self, info):
def embed_lyrics(self, input_files):
audio_file = input_files[0]
subs = input_files[1]
if len(input_files) > 2:
self.report_warning('More than one subtitle file found. Only one will be embedded')
if not subs.endswith('.lrc'):
raise PostProcessingError('LRC subtitles required. Use "--convert-subs lrc" to convert')
@ -679,7 +681,7 @@ def embed_lyrics(self, input_files):
lyrics = f.read().strip()
if audio_file.endswith('.mp3'):
audio = mutagen.id3.ID3(audio_file)
audio.add(mutagen.id3.USLT(encoding=3, lang='eng', desc='', text=lyrics))
audio.add(mutagen.id3.USLT(encoding=mutagen.id3.Encoding.UTF8, lang='und', desc='', text=lyrics))
audio.save()
else:
metadata = mutagen.File(audio_file)