From b6884fbd2f0187e090563bddfdccb53f2b4d93b0 Mon Sep 17 00:00:00 2001 From: Katie Pratt Date: Tue, 8 Oct 2019 23:26:49 -0400 Subject: [PATCH] updating to support cli functionality --- youtube_dl/__init__.py | 14 +++++++++++--- youtube_dl/options.py | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 1251688b4..03066181a 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -276,10 +276,18 @@ def _real_main(argv=None): # source and target containers. From this point the container won't change, # so metadata can be added here. if opts.addmetadata: - postprocessors.append({ - 'key': 'FFmpegMetadata', - 'preferredinfo': json.load(opts.preferredinfo), + if hasattr(opts, 'preferredinfo'): + with open(opts.preferredinfo) as read_file: + preferredinfo = json.load(read_file) + postprocessors.append({ + 'key': 'FFmpegMetadata', + 'preferredinfo': preferredinfo, + }) + else: + postprocessors.append({ + 'key': 'FFmpegMetadata' }) + if opts.convertsubtitles: postprocessors.append({ diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 1ffabc62b..f3335c564 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -818,6 +818,10 @@ def parseOpts(overrideArguments=None): '--add-metadata', action='store_true', dest='addmetadata', default=False, help='Write metadata to the video file') + postproc.add_option( + '--preferred-info', + dest='preferredinfo', metavar='FILE', + help='Override metadata on the outputted file') postproc.add_option( '--metadata-from-title', metavar='FORMAT', dest='metafromtitle',