mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 09:41:26 +01:00
Compare commits
4 Commits
8c31540e3a
...
e9a49de89c
Author | SHA1 | Date | |
---|---|---|---|
|
e9a49de89c | ||
|
823543c2a4 | ||
|
51af60e6d7 | ||
|
79bb8f51e4 |
|
@ -100,12 +100,12 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||||
del audio['APIC']
|
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=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())
|
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:
|
||||||
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
|
success = False
|
||||||
# Method 2: Use ffmpeg
|
# Method 2: Use ffmpeg
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -639,6 +639,7 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
if not mp4_ass_warn and ext == 'mp4' and sub_ext == 'ass':
|
if not mp4_ass_warn and ext == 'mp4' and sub_ext == 'ass':
|
||||||
mp4_ass_warn = True
|
mp4_ass_warn = True
|
||||||
self.report_warning('ASS subtitles cannot be properly embedded in mp4 files; expect issues')
|
self.report_warning('ASS subtitles cannot be properly embedded in mp4 files; expect issues')
|
||||||
|
|
||||||
if not sub_langs:
|
if not sub_langs:
|
||||||
return [], info
|
return [], info
|
||||||
|
|
||||||
|
@ -672,19 +673,21 @@ class FFmpegEmbedSubtitlePP(FFmpegPostProcessor):
|
||||||
def embed_lyrics(self, input_files):
|
def embed_lyrics(self, input_files):
|
||||||
audio_file = input_files[0]
|
audio_file = input_files[0]
|
||||||
subs = input_files[1]
|
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'):
|
if not subs.endswith('.lrc'):
|
||||||
raise PostProcessingError('LRC subtitles required. Use "--convert-subs lrc" to convert')
|
raise PostProcessingError('LRC subtitles required. Use "--convert-subs lrc" to convert')
|
||||||
|
|
||||||
|
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=mutagen.id3.Encoding.UTF8, lang='und', desc='', text=lyrics))
|
||||||
|
audio.save()
|
||||||
else:
|
else:
|
||||||
with open(subs, 'r', encoding='utf-8') as f:
|
metadata = mutagen.File(audio_file)
|
||||||
lyrics = f.read().strip()
|
metadata['©lyr' if audio_file.endswith('.m4a') else 'lyrics'] = [lyrics]
|
||||||
if audio_file.endswith('.mp3'):
|
metadata.save()
|
||||||
audio = mutagen.id3.ID3(audio_file)
|
|
||||||
audio.add(mutagen.id3.USLT(encoding=3, lang='eng', desc='', text=lyrics))
|
|
||||||
audio.save()
|
|
||||||
else:
|
|
||||||
metadata = mutagen.File(audio_file)
|
|
||||||
metadata['©lyr' if audio_file.endswith('.m4a') else 'lyrics'] = [lyrics]
|
|
||||||
metadata.save()
|
|
||||||
|
|
||||||
|
|
||||||
class FFmpegMetadataPP(FFmpegPostProcessor):
|
class FFmpegMetadataPP(FFmpegPostProcessor):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user