mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
[bilibili] add support for live.bilibili.com (close #986)
This commit is contained in:
parent
2a80fb5d5b
commit
80ea797cb6
@ -98,13 +98,23 @@ def bilibili_download_by_cid(cid, title, output_dir='.', merge=True, info_only=F
|
|||||||
if not info_only:
|
if not info_only:
|
||||||
download_urls(urls, title, type_, total_size=None, output_dir=output_dir, merge=merge)
|
download_urls(urls, title, type_, total_size=None, output_dir=output_dir, merge=merge)
|
||||||
|
|
||||||
|
def bilibili_live_download_by_cid(cid, title, output_dir='.', merge=True, info_only=False):
|
||||||
|
api_url = 'http://live.bilibili.com/api/playurl?cid=' + cid
|
||||||
|
urls = parse_cid_playurl(get_content(api_url))
|
||||||
|
|
||||||
|
for url in urls:
|
||||||
|
_, type_, _ = url_info(url)
|
||||||
|
size = 0
|
||||||
|
print_info(site_info, title, type_, size)
|
||||||
|
if not info_only:
|
||||||
|
download_urls([url], title, type_, total_size=None, output_dir=output_dir, merge=merge)
|
||||||
|
|
||||||
def bilibili_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
def bilibili_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
||||||
html = get_content(url)
|
html = get_content(url)
|
||||||
|
|
||||||
title = r1_of([r'<meta name="title" content="([^<>]{1,999})" />',
|
title = r1_of([r'<meta name="title" content="([^<>]{1,999})" />',
|
||||||
r'<h1[^>]*>([^<>]+)</h1>'], html)
|
r'<h1[^>]*>([^<>]+)</h1>'], html)
|
||||||
if not title:
|
if title:
|
||||||
log.wtf('[Failed] Video does not exist. Try to login with --cookies.')
|
|
||||||
title = unescape_html(title)
|
title = unescape_html(title)
|
||||||
title = escape_file_path(title)
|
title = escape_file_path(title)
|
||||||
|
|
||||||
@ -114,7 +124,10 @@ def bilibili_download(url, output_dir='.', merge=True, info_only=False, **kwargs
|
|||||||
t, cid = flashvars.split('=', 1)
|
t, cid = flashvars.split('=', 1)
|
||||||
cid = cid.split('&')[0]
|
cid = cid.split('&')[0]
|
||||||
if t == 'cid':
|
if t == 'cid':
|
||||||
if 'playlist' in kwargs and kwargs['playlist']:
|
if re.match(r'https?://live\.bilibili\.com/', url):
|
||||||
|
title = r1(r'<title>([^<>]+)</title>', html)
|
||||||
|
bilibili_live_download_by_cid(cid, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
|
elif 'playlist' in kwargs and kwargs['playlist']:
|
||||||
# multi-P
|
# multi-P
|
||||||
cids = []
|
cids = []
|
||||||
pages = re.findall('<option value=\'([^\']*)\'', html)
|
pages = re.findall('<option value=\'([^\']*)\'', html)
|
||||||
|
Loading…
Reference in New Issue
Block a user