diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index ace17857c..89192b3d3 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -367,6 +367,7 @@ def _real_main(argv=None): 'hls_prefer_native': opts.hls_prefer_native, 'external_downloader_args': external_downloader_args, 'cn_verification_proxy': opts.cn_verification_proxy, + 'custommeta': opts.custommeta, } with YoutubeDL(ydl_opts) as ydl: diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 740458e51..8427a58e5 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -707,6 +707,16 @@ def parseOpts(overrideArguments=None): '--add-metadata', action='store_true', dest='addmetadata', default=False, help='Write metadata to the video file') + postproc.add_option( + '--custom-meta', + action='append', dest='custommeta', default=[], + help='Write specific information to a metadata tag.' + 'Syntax: "tagname=string to add with %(format)s" ' + 'The formatting syntax is the same as output. ' + 'Example: --custom-meta "comment=%(webpage_url)s\\n%(description)s" will ' + 'add a line with the url, then the description in the "comment" tag. ' + 'Tags are format-specific, common ones include: artist, comment, title, copyright, uploader. ' + 'This can be invoked multiple times for different tags.') postproc.add_option( '--metadata-from-title', metavar='FORMAT', dest='metafromtitle', diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index fe7e0a8ee..c27c0db3b 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -367,6 +367,10 @@ class FFmpegMetadataPP(FFmpegPostProcessor): if info.get('album') is not None: metadata['album'] = info['album'] + for m in self._downloader.params.get('custommeta'): + key,val = m.split('=',1) + metadata[key] = val.replace('\\n', '\n') % info + if not metadata: self._downloader.to_screen('[ffmpeg] There isn\'t any metadata to add') return [], info