mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 17:51:24 +01:00
Compare commits
No commits in common. "e9a49de89cb68c1f674d53003a6b07643edb2ab0" and "8c31540e3ab91da858cc0ca742f0e9e2117a0d9d" have entirely different histories.
e9a49de89c
...
8c31540e3a
|
@ -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=mutagen.id3.Encoding.UTF8, mime='image/%s' % thumbnail_ext, type=3,
|
encoding=3, 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(f'unable to embed using mutagen; {err}')
|
self.report_warning('unable to embed using mutagen; %s' % error_to_compat_str(err))
|
||||||
success = False
|
success = False
|
||||||
# Method 2: Use ffmpeg
|
# Method 2: Use ffmpeg
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -639,7 +639,6 @@ 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
|
||||||
|
|
||||||
|
@ -673,21 +672,19 @@ 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:
|
||||||
metadata = mutagen.File(audio_file)
|
with open(subs, 'r', encoding='utf-8') as f:
|
||||||
metadata['©lyr' if audio_file.endswith('.m4a') else 'lyrics'] = [lyrics]
|
lyrics = f.read().strip()
|
||||||
metadata.save()
|
if audio_file.endswith('.mp3'):
|
||||||
|
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