mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 08:43:58 +03:00
try support stream vedio
This commit is contained in:
parent
14d05d3b20
commit
5bfb7650b3
@ -199,14 +199,17 @@ def url_size(url, faker = False):
|
|||||||
else:
|
else:
|
||||||
response = request.urlopen(url)
|
response = request.urlopen(url)
|
||||||
|
|
||||||
size = int(response.headers['content-length'])
|
size = response.headers['content-length']
|
||||||
return size
|
return int(size) if size!=None else None
|
||||||
|
|
||||||
# TO BE DEPRECATED
|
# TO BE DEPRECATED
|
||||||
# urls_size() does not have a faker
|
# urls_size() does not have a faker
|
||||||
# also it takes too long time
|
# also it takes too long time
|
||||||
def urls_size(urls):
|
def urls_size(urls):
|
||||||
return sum(map(url_size, urls))
|
try:
|
||||||
|
return sum(map(url_size, urls))
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def url_info(url, faker = False):
|
def url_info(url, faker = False):
|
||||||
if faker:
|
if faker:
|
||||||
@ -245,8 +248,8 @@ def url_info(url, faker = False):
|
|||||||
else:
|
else:
|
||||||
ext = None
|
ext = None
|
||||||
|
|
||||||
if headers['transfer-encoding'] != 'chunked':
|
if headers['transfer-encoding'] != 'chunked' and headers['content-length']:
|
||||||
size = int(headers['content-length'] or '-1')
|
size = int(headers['content-length'])
|
||||||
else:
|
else:
|
||||||
size = None
|
size = None
|
||||||
|
|
||||||
@ -491,7 +494,6 @@ def download_urls(urls, title, ext, total_size, output_dir='.', refer=None, merg
|
|||||||
import sys
|
import sys
|
||||||
traceback.print_exc(file = sys.stdout)
|
traceback.print_exc(file = sys.stdout)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
title = tr(get_filename(title))
|
title = tr(get_filename(title))
|
||||||
|
|
||||||
filename = '%s.%s' % (title, ext)
|
filename = '%s.%s' % (title, ext)
|
||||||
@ -717,7 +719,10 @@ def print_info(site_info, title, type, size):
|
|||||||
print("Video Site:", site_info)
|
print("Video Site:", site_info)
|
||||||
print("Title: ", unescape_html(tr(title)))
|
print("Title: ", unescape_html(tr(title)))
|
||||||
print("Type: ", type_info)
|
print("Type: ", type_info)
|
||||||
print("Size: ", round(size / 1048576, 2), "MiB (" + str(size) + " Bytes)")
|
if size:
|
||||||
|
print("Size: ", round(size / 1048576, 2), "MiB (" + str(size) + " Bytes)")
|
||||||
|
else:
|
||||||
|
print("Size: ", "Unknow")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def mime_to_container(mime):
|
def mime_to_container(mime):
|
||||||
|
@ -13,6 +13,7 @@ def douyutv_download(url, output_dir = '.', merge = True, info_only = False):
|
|||||||
|
|
||||||
roomid = re.findall(room_id_patt,html)[0]
|
roomid = re.findall(room_id_patt,html)[0]
|
||||||
title = unescape_html(re.findall(title_patt,html)[0])
|
title = unescape_html(re.findall(title_patt,html)[0])
|
||||||
|
print(title)
|
||||||
|
|
||||||
conf = get_html("http://www.douyutv.com/api/client/room/"+roomid)
|
conf = get_html("http://www.douyutv.com/api/client/room/"+roomid)
|
||||||
metadata = json.loads(conf)
|
metadata = json.loads(conf)
|
||||||
|
Loading…
Reference in New Issue
Block a user