From 55faba7ed77abad9dfe00bf850b9f8c4b04b036d Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 15 Nov 2020 01:42:07 +0530 Subject: Fix for os.rename error when embedding thumbnail to video in a different drive --- youtube_dlc/postprocessor/embedthumbnail.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'youtube_dlc/postprocessor/embedthumbnail.py') diff --git a/youtube_dlc/postprocessor/embedthumbnail.py b/youtube_dlc/postprocessor/embedthumbnail.py index 4a0d02fc4..a7d53d7f5 100644 --- a/youtube_dlc/postprocessor/embedthumbnail.py +++ b/youtube_dlc/postprocessor/embedthumbnail.py @@ -89,9 +89,10 @@ class EmbedThumbnailPP(FFmpegPostProcessor): os.rename(encodeFilename(temp_filename), encodeFilename(filename)) elif info['ext'] == 'mkv': - os.rename(encodeFilename(thumbnail_filename), encodeFilename('cover.jpg')) old_thumbnail_filename = thumbnail_filename - thumbnail_filename = 'cover.jpg' + thumbnail_filename = os.path.join(os.path.dirname(old_thumbnail_filename), 'cover.jpg') + os.remove(encodeFilename(thumbnail_filename)) + os.rename(encodeFilename(old_thumbnail_filename), encodeFilename(thumbnail_filename)) options = [ '-c', 'copy', '-attach', thumbnail_filename, '-metadata:s:t', 'mimetype=image/jpeg'] -- cgit v1.2.3 From 958804ad4e019ce59c6b5d72918dff846839220c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 15 Nov 2020 01:38:54 +0530 Subject: Ensure all streams are copied when using ffmpeg --- youtube_dlc/postprocessor/embedthumbnail.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'youtube_dlc/postprocessor/embedthumbnail.py') diff --git a/youtube_dlc/postprocessor/embedthumbnail.py b/youtube_dlc/postprocessor/embedthumbnail.py index 4a0d02fc4..7ca0ce6e5 100644 --- a/youtube_dlc/postprocessor/embedthumbnail.py +++ b/youtube_dlc/postprocessor/embedthumbnail.py @@ -94,7 +94,8 @@ class EmbedThumbnailPP(FFmpegPostProcessor): thumbnail_filename = 'cover.jpg' options = [ - '-c', 'copy', '-attach', thumbnail_filename, '-metadata:s:t', 'mimetype=image/jpeg'] + '-c', 'copy', '-map', '0', + '-attach', thumbnail_filename, '-metadata:s:t', 'mimetype=image/jpeg'] self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename) @@ -140,6 +141,6 @@ class EmbedThumbnailPP(FFmpegPostProcessor): os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) else: - raise EmbedThumbnailPPError('Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.') + raise EmbedThumbnailPPError('Only mp3, mkv, m4a and mp4 are supported for thumbnail embedding for now.') return [], info -- cgit v1.2.3 From ec57f903c907bf8c48c9cd3eea75e6dadb855595 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sun, 15 Nov 2020 04:18:39 +0530 Subject: Don't try to delete file if it doesn't exist --- youtube_dlc/postprocessor/embedthumbnail.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'youtube_dlc/postprocessor/embedthumbnail.py') diff --git a/youtube_dlc/postprocessor/embedthumbnail.py b/youtube_dlc/postprocessor/embedthumbnail.py index a7d53d7f5..2ff3cff69 100644 --- a/youtube_dlc/postprocessor/embedthumbnail.py +++ b/youtube_dlc/postprocessor/embedthumbnail.py @@ -91,7 +91,8 @@ class EmbedThumbnailPP(FFmpegPostProcessor): elif info['ext'] == 'mkv': old_thumbnail_filename = thumbnail_filename thumbnail_filename = os.path.join(os.path.dirname(old_thumbnail_filename), 'cover.jpg') - os.remove(encodeFilename(thumbnail_filename)) + if os.path.exists(thumbnail_filename): + os.remove(encodeFilename(thumbnail_filename)) os.rename(encodeFilename(old_thumbnail_filename), encodeFilename(thumbnail_filename)) options = [ -- cgit v1.2.3