mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
Bilibili: fix #341
This commit is contained in:
parent
c7cc66458f
commit
6046cb78a8
@ -40,7 +40,7 @@ __中文说明__已移至[wiki](https://github.com/soimort/you-get/wiki/%E4%B8%A
|
|||||||
* Tudou (土豆) <http://www.tudou.com>
|
* Tudou (土豆) <http://www.tudou.com>
|
||||||
* YinYueTai (音悦台) <http://www.yinyuetai.com>
|
* YinYueTai (音悦台) <http://www.yinyuetai.com>
|
||||||
* AcFun <http://www.acfun.com>
|
* AcFun <http://www.acfun.com>
|
||||||
* bilibili <http://www.bilibili.tv>
|
* bilibili <http://www.bilibili.com>
|
||||||
* CNTV (中国网络电视台) <http://www.cntv.cn>
|
* CNTV (中国网络电视台) <http://www.cntv.cn>
|
||||||
* Douban (豆瓣) <http://douban.com>
|
* Douban (豆瓣) <http://douban.com>
|
||||||
* ifeng (凤凰视频) <http://v.ifeng.com>
|
* ifeng (凤凰视频) <http://v.ifeng.com>
|
||||||
|
@ -43,7 +43,7 @@ Supported Sites (As of Now)
|
|||||||
* Tudou (土豆) http://www.tudou.com
|
* Tudou (土豆) http://www.tudou.com
|
||||||
* YinYueTai (音悦台) http://www.yinyuetai.com
|
* YinYueTai (音悦台) http://www.yinyuetai.com
|
||||||
* AcFun http://www.acfun.com
|
* AcFun http://www.acfun.com
|
||||||
* bilibili http://www.bilibili.tv
|
* bilibili http://www.bilibili.com
|
||||||
* CNTV (中国网络电视台) http://www.cntv.cn
|
* CNTV (中国网络电视台) http://www.cntv.cn
|
||||||
* Douban (豆瓣) http://douban.com
|
* Douban (豆瓣) http://douban.com
|
||||||
* ifeng (凤凰视频) http://v.ifeng.com
|
* ifeng (凤凰视频) http://v.ifeng.com
|
||||||
|
@ -11,7 +11,7 @@ from .youku import youku_download_by_id
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
def get_srt_xml(id):
|
def get_srt_xml(id):
|
||||||
url = 'http://comment.bilibili.tv/%s.xml' % id
|
url = 'http://comment.bilibili.com/%s.xml' % id
|
||||||
return get_html(url)
|
return get_html(url)
|
||||||
|
|
||||||
def parse_srt_p(p):
|
def parse_srt_p(p):
|
||||||
@ -54,7 +54,7 @@ def parse_cid_playurl(xml):
|
|||||||
return urls
|
return urls
|
||||||
|
|
||||||
def bilibili_download_by_cid(id, title, output_dir = '.', merge = True, info_only = False):
|
def bilibili_download_by_cid(id, title, output_dir = '.', merge = True, info_only = False):
|
||||||
url = 'http://interface.bilibili.tv/playurl?cid=' + id
|
url = 'http://interface.bilibili.com/playurl?cid=' + id
|
||||||
urls = [i if not re.match(r'.*\.qqvideo\.tc\.qq\.com', i) else re.sub(r'.*\.qqvideo\.tc\.qq\.com', 'http://vsrc.store.qq.com', i) for i in parse_cid_playurl(get_html(url, 'utf-8'))] # dirty fix for QQ
|
urls = [i if not re.match(r'.*\.qqvideo\.tc\.qq\.com', i) else re.sub(r'.*\.qqvideo\.tc\.qq\.com', 'http://vsrc.store.qq.com', i) for i in parse_cid_playurl(get_html(url, 'utf-8'))] # dirty fix for QQ
|
||||||
|
|
||||||
if re.search(r'\.(flv|hlv)\b', urls[0]):
|
if re.search(r'\.(flv|hlv)\b', urls[0]):
|
||||||
@ -76,14 +76,13 @@ def bilibili_download_by_cid(id, title, output_dir = '.', merge = True, info_onl
|
|||||||
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_download(url, output_dir = '.', merge = True, info_only = False):
|
def bilibili_download(url, output_dir = '.', merge = True, info_only = False):
|
||||||
assert re.match(r'http://(www.bilibili.tv|bilibili.kankanews.com|bilibili.smgbb.cn)/video/av(\d+)', url)
|
|
||||||
html = get_html(url)
|
html = get_html(url)
|
||||||
|
|
||||||
title = r1(r'<h2[^>]*>([^<>]+)</h2>', html)
|
title = r1(r'<h2[^>]*>([^<>]+)</h2>', html)
|
||||||
title = unescape_html(title)
|
title = unescape_html(title)
|
||||||
title = escape_file_path(title)
|
title = escape_file_path(title)
|
||||||
|
|
||||||
flashvars = r1_of([r'player_params=\'(cid=\d+)', r'flashvars="([^"]+)"', r'"https://[a-z]+\.bilibili\.tv/secure,(cid=\d+)(?:&aid=\d+)?"'], html)
|
flashvars = r1_of([r'player_params=\'(cid=\d+)', r'flashvars="([^"]+)"', r'"https://[a-z]+\.bilibili\.com/secure,(cid=\d+)(?:&aid=\d+)?"'], html)
|
||||||
assert flashvars
|
assert flashvars
|
||||||
t, id = flashvars.split('=', 1)
|
t, id = flashvars.split('=', 1)
|
||||||
id = id.split('&')[0]
|
id = id.split('&')[0]
|
||||||
@ -105,6 +104,6 @@ def bilibili_download(url, output_dir = '.', merge = True, info_only = False):
|
|||||||
with open(os.path.join(output_dir, title + '.cmt.xml'), 'w', encoding='utf-8') as x:
|
with open(os.path.join(output_dir, title + '.cmt.xml'), 'w', encoding='utf-8') as x:
|
||||||
x.write(xml)
|
x.write(xml)
|
||||||
|
|
||||||
site_info = "bilibili.tv"
|
site_info = "bilibili.com"
|
||||||
download = bilibili_download
|
download = bilibili_download
|
||||||
download_playlist = playlist_not_supported('bilibili')
|
download_playlist = playlist_not_supported('bilibili')
|
||||||
|
Loading…
Reference in New Issue
Block a user