YoutubeDL: support download of videos splitted in parts

This commit is contained in:
Jaime Marquínez Ferrándiz 2013-07-05 11:08:25 +02:00
parent 529a2e2cc3
commit 3a6e739da4
2 changed files with 18 additions and 1 deletions

View File

@ -773,7 +773,23 @@ class YoutubeDL(object):
success = True
else:
try:
success = self.fd._do_download(filename, info_dict)
parts = info_dict.get('parts',[])
if not parts:
success = self.fd._do_download(filename, info_dict)
elif len(parts) == 1:
info_dict['url'] = parts[0]
success = self.fd._do_download(filename, info_dict)
else:
parts_success = []
parts_files = []
self.to_screen(u'[info] Downloading %s parts' % len(parts))
for (i, part_url) in enumerate(parts):
part_info = dict(info_dict)
part_info['url'] = part_url
part_filename = u'%s.%s' % (filename, i)
parts_files.append(part_filename)
parts_success.append(self.fd._do_download(part_filename, part_info))
success = all(parts_success)
except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self.report_error(u'unable to download video data: %s' % str(err))
return

View File

@ -55,6 +55,7 @@ class InfoExtractor(object):
subtitles: The subtitle file contents as a dictionary in the format
{language: subtitles}.
view_count: How many users have watched the video on the platform.
parts: A list of urls for each of the parts of the video.
urlhandle: [internal] The urlHandle to be used to download the file,
like returned by urllib.request.urlopen
age_limit: Age restriction for the video, as an integer (years)