mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-04 20:40:37 +00:00
[postprocessor/embedthumbnail] Add FLAC support
This commit is contained in:
parent
a803582717
commit
6091b64448
@ -124,7 +124,31 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
|
||||
else:
|
||||
os.remove(encodeFilename(filename))
|
||||
os.rename(encodeFilename(temp_filename), encodeFilename(filename))
|
||||
elif info['ext'] == 'flac':
|
||||
if not check_executable('metaflac', ['--help']):
|
||||
raise EmbedThumbnailPPError('metaflac was not found. Please install.')
|
||||
|
||||
cmd = [encodeFilename('metaflac', True),
|
||||
encodeArgument('--preserve-modtime'),
|
||||
encodeArgument('--import-picture-from'),
|
||||
encodeFilename(thumbnail_filename, True),
|
||||
encodeFilename(filename, True)]
|
||||
|
||||
self._downloader.to_screen('[metaflac] Adding thumbnail to "%s"' % filename)
|
||||
|
||||
if self._downloader.params.get('verbose', False):
|
||||
self._downloader.to_screen('[debug] metaflac command line: %s' % shell_quote(cmd))
|
||||
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
if p.returncode != 0:
|
||||
msg = stderr.decode('utf-8', 'replace').strip()
|
||||
raise EmbedThumbnailPPError(msg)
|
||||
|
||||
if not self._already_have_thumbnail:
|
||||
os.remove(encodeFilename(thumbnail_filename))
|
||||
else:
|
||||
raise EmbedThumbnailPPError('Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.')
|
||||
raise EmbedThumbnailPPError('Only mp3, m4a/mp4, and flac are supported for thumbnail embedding for now.')
|
||||
|
||||
return [], info
|
||||
|
Loading…
Reference in New Issue
Block a user