diff options
author | pukkandan <pukkandan@gmail.com> | 2021-02-03 19:06:09 +0530 |
---|---|---|
committer | pukkandan <pukkandan@gmail.com> | 2021-02-05 04:11:39 +0530 |
commit | de6000d913fd35643cb6faf89919665ddd9ab225 (patch) | |
tree | 6960b6211f37df02e81189f88bdcbd3267edfcfd /youtube_dlc/postprocessor | |
parent | ff88a05cff49ec1a2d6b93c0a420b63537fd6f42 (diff) | |
download | hypervideo-pre-de6000d913fd35643cb6faf89919665ddd9ab225.tar.lz hypervideo-pre-de6000d913fd35643cb6faf89919665ddd9ab225.tar.xz hypervideo-pre-de6000d913fd35643cb6faf89919665ddd9ab225.zip |
Multiple output templates for different file types
Syntax: -o common_template -o type:type_template
Types supported: subtitle|thumbnail|description|annotation|infojson|pl_description|pl_infojson
Diffstat (limited to 'youtube_dlc/postprocessor')
-rw-r--r-- | youtube_dlc/postprocessor/embedthumbnail.py | 9 | ||||
-rw-r--r-- | youtube_dlc/postprocessor/ffmpeg.py | 4 | ||||
-rw-r--r-- | youtube_dlc/postprocessor/movefilesafterdownload.py | 3 |
3 files changed, 11 insertions, 5 deletions
diff --git a/youtube_dlc/postprocessor/embedthumbnail.py b/youtube_dlc/postprocessor/embedthumbnail.py index 334e05955..da6b6797f 100644 --- a/youtube_dlc/postprocessor/embedthumbnail.py +++ b/youtube_dlc/postprocessor/embedthumbnail.py @@ -42,6 +42,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor): def run(self, info): filename = info['filepath'] temp_filename = prepend_extension(filename, 'temp') + files_to_delete = [] if not info.get('thumbnails'): self.to_screen('There aren\'t any thumbnails to embed') @@ -78,7 +79,7 @@ class EmbedThumbnailPP(FFmpegPostProcessor): escaped_thumbnail_jpg_filename = replace_extension(escaped_thumbnail_filename, 'jpg') self.to_screen('Converting thumbnail "%s" to JPEG' % escaped_thumbnail_filename) self.run_ffmpeg(escaped_thumbnail_filename, escaped_thumbnail_jpg_filename, ['-bsf:v', 'mjpeg2jpeg']) - os.remove(encodeFilename(escaped_thumbnail_filename)) + files_to_delete.append(escaped_thumbnail_filename) thumbnail_jpg_filename = replace_extension(thumbnail_filename, 'jpg') # Rename back to unescaped for further processing os.rename(encodeFilename(escaped_thumbnail_jpg_filename), encodeFilename(thumbnail_jpg_filename)) @@ -183,5 +184,9 @@ class EmbedThumbnailPP(FFmpegPostProcessor): if success and temp_filename != filename: os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) - files_to_delete = [] if self._already_have_thumbnail else [thumbnail_filename] + if self._already_have_thumbnail: + info['__files_to_move'][thumbnail_filename] = replace_extension( + info['__thumbnail_filename'], os.path.splitext(thumbnail_filename)[1][1:]) + else: + files_to_delete.append(thumbnail_filename) return files_to_delete, info diff --git a/youtube_dlc/postprocessor/ffmpeg.py b/youtube_dlc/postprocessor/ffmpeg.py index a364237ce..948c34287 100644 --- a/youtube_dlc/postprocessor/ffmpeg.py +++ b/youtube_dlc/postprocessor/ffmpeg.py @@ -578,7 +578,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): in_filenames.append(metadata_filename) options.extend(['-map_metadata', '1']) - if '__infojson_filepath' in info and info['ext'] in ('mkv', 'mka'): + if '__infojson_filename' in info and info['ext'] in ('mkv', 'mka'): old_stream, new_stream = self.get_stream_number( filename, ('tags', 'mimetype'), 'application/json') if old_stream is not None: @@ -586,7 +586,7 @@ class FFmpegMetadataPP(FFmpegPostProcessor): new_stream -= 1 options.extend([ - '-attach', info['__infojson_filepath'], + '-attach', info['__infojson_filename'], '-metadata:s:%d' % new_stream, 'mimetype=application/json' ]) diff --git a/youtube_dlc/postprocessor/movefilesafterdownload.py b/youtube_dlc/postprocessor/movefilesafterdownload.py index 7dcf12a3b..7f34ac5c5 100644 --- a/youtube_dlc/postprocessor/movefilesafterdownload.py +++ b/youtube_dlc/postprocessor/movefilesafterdownload.py @@ -25,6 +25,7 @@ class MoveFilesAfterDownloadPP(PostProcessor): dl_path, dl_name = os.path.split(encodeFilename(info['filepath'])) finaldir = info.get('__finaldir', dl_path) finalpath = os.path.join(finaldir, dl_name) + self.files_to_move.update(info['__files_to_move']) self.files_to_move[info['filepath']] = finalpath for oldfile, newfile in self.files_to_move.items(): @@ -39,7 +40,7 @@ class MoveFilesAfterDownloadPP(PostProcessor): if os.path.exists(encodeFilename(newfile)): if self.get_param('overwrites', True): self.report_warning('Replacing existing file "%s"' % newfile) - os.path.remove(encodeFilename(newfile)) + os.remove(encodeFilename(newfile)) else: self.report_warning( 'Cannot move file "%s" out of temporary directory since "%s" already exists. ' |