aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor/embedthumbnail.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-03-18 20:54:53 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-03-18 20:54:53 +0530
commitdcf64d43e0b3a205ebce565d1cf7e71955916824 (patch)
tree5bffee1f9c9500d18747822e1651854070ca7052 /yt_dlp/postprocessor/embedthumbnail.py
parente3c076970eb04ea8fecf0598c3b2220e9f656ef5 (diff)
downloadhypervideo-pre-dcf64d43e0b3a205ebce565d1cf7e71955916824.tar.lz
hypervideo-pre-dcf64d43e0b3a205ebce565d1cf7e71955916824.tar.xz
hypervideo-pre-dcf64d43e0b3a205ebce565d1cf7e71955916824.zip
[movefiles] Fix bugs and make more robust
Diffstat (limited to 'yt_dlp/postprocessor/embedthumbnail.py')
-rw-r--r--yt_dlp/postprocessor/embedthumbnail.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py
index 82e7e2004..7f759cc30 100644
--- a/yt_dlp/postprocessor/embedthumbnail.py
+++ b/yt_dlp/postprocessor/embedthumbnail.py
@@ -47,7 +47,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
self.to_screen('There aren\'t any thumbnails to embed')
return [], info
- original_thumbnail = thumbnail_filename = info['thumbnails'][-1]['filename']
+ initial_thumbnail = original_thumbnail = thumbnail_filename = info['thumbnails'][-1]['filepath']
if not os.path.exists(encodeFilename(thumbnail_filename)):
self.report_warning('Skipping embedding the thumbnail because the file is missing.')
@@ -65,6 +65,8 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
if thumbnail_ext != 'webp' and is_webp(thumbnail_filename):
self.to_screen('Correcting extension to webp and escaping path for thumbnail "%s"' % thumbnail_filename)
thumbnail_webp_filename = replace_extension(thumbnail_filename, 'webp')
+ if os.path.exists(thumbnail_webp_filename):
+ os.remove(thumbnail_webp_filename)
os.rename(encodeFilename(thumbnail_filename), encodeFilename(thumbnail_webp_filename))
original_thumbnail = thumbnail_filename = thumbnail_webp_filename
thumbnail_ext = 'webp'
@@ -194,7 +196,8 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
files_to_delete = [thumbnail_filename]
if self._already_have_thumbnail:
info['__files_to_move'][original_thumbnail] = replace_extension(
- info['__thumbnail_filename'], os.path.splitext(original_thumbnail)[1][1:])
+ info['__files_to_move'][initial_thumbnail],
+ os.path.splitext(original_thumbnail)[1][1:])
if original_thumbnail == thumbnail_filename:
files_to_delete = []
elif original_thumbnail != thumbnail_filename: