Compare commits

...

4 Commits

Author SHA1 Message Date
Rohit
e9a49de89c added the newline back which i removed by mistake 2023-12-29 22:37:54 +05:30
Rohit
823543c2a4 Fix encoding issues in embedthumbnail.py and embed_lyrics() 2023-12-29 22:11:18 +05:30
fjueic
51af60e6d7
Update yt_dlp/postprocessor/ffmpeg.py
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
2023-12-29 07:38:41 -08:00
fjueic
79bb8f51e4
Update yt_dlp/postprocessor/embedthumbnail.py
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
2023-12-29 07:37:00 -08:00
2 changed files with 15 additions and 12 deletions

View File

@ -100,12 +100,12 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
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
except Exception as err:
self.report_warning('unable to embed using mutagen; %s' % error_to_compat_str(err))
self.report_warning(f'unable to embed using mutagen; {err}')
success = False
# Method 2: Use ffmpeg
else:

View File

@ -639,6 +639,7 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
if not mp4_ass_warn and ext == 'mp4' and sub_ext == 'ass':
mp4_ass_warn = True
self.report_warning('ASS subtitles cannot be properly embedded in mp4 files; expect issues')
if not sub_langs:
return [], info
@ -672,14 +673,16 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
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')
else:
with open(subs, 'r', encoding='utf-8') as f:
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)