aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-12-09 04:55:02 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2013-12-09 04:55:02 +0100
commitdb4da140273d119e6f75445ee6f8cc286523b63e (patch)
tree59e240a87e72b035071d74f8816845685b85ca00 /youtube_dl
parent2101830c0d27e6d9ad2f564ff004565e71da1ec5 (diff)
parentd494389821de832874dc78abc2fe16365b5fe815 (diff)
Merge remote-tracking branch 'jaimeMF/load-info'
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/YoutubeDL.py15
-rw-r--r--youtube_dl/__init__.py10
2 files changed, 23 insertions, 2 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 17b3827f2..79d5c7e5e 100644
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -882,6 +882,21 @@ class YoutubeDL(object):
return self._download_retcode
+ def download_with_info_file(self, info_filename):
+ with open(info_filename, 'r') as f:
+ # TODO: Check for errors
+ info = json.load(f)
+ try:
+ self.process_ie_result(info, download=True)
+ except DownloadError:
+ webpage_url = info.get('webpage_url')
+ if webpage_url is not None:
+ self.report_warning(u'The info failed to download, trying with "%s"' % webpage_url)
+ return self.download([webpage_url])
+ else:
+ raise
+ return self._download_retcode
+
def post_process(self, filename, ie_info):
"""Run all the postprocessors on the given file."""
info = dict(ie_info)
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 2e3f96919..6e9dd68c4 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -363,6 +363,9 @@ def parseOpts(overrideArguments=None):
help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames', default=False)
filesystem.add_option('-a', '--batch-file',
dest='batchfile', metavar='FILE', help='file containing URLs to download (\'-\' for stdin)')
+ filesystem.add_option('--load-info',
+ dest='load_info_filename', metavar='FILE',
+ help='json file containing the video information (created with the "--write-json" option')
filesystem.add_option('-w', '--no-overwrites',
action='store_true', dest='nooverwrites', help='do not overwrite files', default=False)
filesystem.add_option('-c', '--continue',
@@ -710,14 +713,17 @@ def _real_main(argv=None):
update_self(ydl.to_screen, opts.verbose)
# Maybe do nothing
- if len(all_urls) < 1:
+ if (len(all_urls) < 1) and (opts.load_info_filename is None):
if not opts.update_self:
parser.error(u'you must provide at least one URL')
else:
sys.exit()
try:
- retcode = ydl.download(all_urls)
+ if opts.load_info_filename is not None:
+ retcode = ydl.download_with_info_file(opts.load_info_filename)
+ else:
+ retcode = ydl.download(all_urls)
except MaxDownloadsReached:
ydl.to_screen(u'--max-download limit reached, aborting.')
retcode = 101