提交 e71972d4 编写于 作者: M Mort Yao

fix #1: use redirected URLs for resuming of Youku downloads

上级 a4bf334a
......@@ -109,6 +109,13 @@ def url_info(url):
return type, ext, size
def url_locations(urls):
locations = []
for url in urls:
response = request.urlopen(request.Request(url))
locations.append(response.url)
return locations
def url_save(url, filepath, bar, refer = None, is_part = False):
file_size = url_size(url)
......
......@@ -123,11 +123,14 @@ def file_type_of_url(url):
def youku_download_by_id(id2, title, output_dir = '.', stream_type = None, merge = True, info_only = False):
info = get_info(id2)
urls, sizes = zip(*find_video(info, stream_type))
ext = file_type_of_url(urls[0])
total_size = sum(sizes)
print_info(site_info, title, file_type_of_url(urls[0]), total_size)
urls = url_locations(urls) # Use real (redirected) URLs for resuming of downloads
print_info(site_info, title, ext, total_size)
if not info_only:
download_urls(urls, title, file_type_of_url(urls[0]), total_size, output_dir, merge = merge)
download_urls(urls, title, ext, total_size, output_dir, merge = merge)
def youku_download(url, output_dir = '.', stream_type = None, merge = True, info_only = False):
id2, title = parse_page(url)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册