aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/YoutubeDL.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-05-01 00:44:34 +0600
committerSergey M․ <dstftw@gmail.com>2015-05-01 00:44:34 +0600
commitcb202fd28635bf82836a025c631339665ba610af (patch)
treeffb3910ca6dcf522c290773c3057ad9c342b4fc4 /youtube_dl/YoutubeDL.py
parent67fc8ecd53b4ffe5375a741bf0b1282f7a44587d (diff)
downloadyoutube-dl-cb202fd28635bf82836a025c631339665ba610af.tar.xz
[YoutubeDL] Filter requested info fields on `--load-info` as well
In order to properly handle JSON info files generated by youtube-dl versions prior to 4070b458ece46a29dad9be2312a7daa48bb2f1d7
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rwxr-xr-xyoutube_dl/YoutubeDL.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 584dbf8a6..55b429f31 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -1337,11 +1337,8 @@ class YoutubeDL(object):
self.to_screen('[info] Video description metadata is already present')
else:
self.to_screen('[info] Writing video description metadata as JSON to: ' + infofn)
- filtered_info_dict = dict(
- (k, v) for k, v in info_dict.items()
- if k not in ['requested_formats', 'requested_subtitles'])
try:
- write_json_file(filtered_info_dict, infofn)
+ write_json_file(self.filter_requested_info(info_dict), infofn)
except (OSError, IOError):
self.report_error('Cannot write metadata to JSON file ' + infofn)
return
@@ -1491,7 +1488,7 @@ class YoutubeDL(object):
[info_filename], mode='r',
openhook=fileinput.hook_encoded('utf-8'))) as f:
# FileInput doesn't have a read method, we can't call json.load
- info = json.loads('\n'.join(f))
+ info = self.filter_requested_info(json.loads('\n'.join(f)))
try:
self.process_ie_result(info, download=True)
except DownloadError:
@@ -1503,6 +1500,12 @@ class YoutubeDL(object):
raise
return self._download_retcode
+ @staticmethod
+ def filter_requested_info(info_dict):
+ return dict(
+ (k, v) for k, v in info_dict.items()
+ if k not in ['requested_formats', 'requested_subtitles'])
+
def post_process(self, filename, ie_info):
"""Run all the postprocessors on the given file."""
info = dict(ie_info)