Bilibili: fix #341

This commit is contained in:
Mort Yao 2014-06-18 01:14:11 +02:00
parent c7cc66458f
commit 6046cb78a8
3 changed files with 6 additions and 7 deletions

View File

@ -40,7 +40,7 @@ __中文说明__已移至[wiki](https://github.com/soimort/you-get/wiki/%E4%B8%A
* Tudou (土豆) <http://www.tudou.com>
* YinYueTai (音悦台) <http://www.yinyuetai.com>
* AcFun <http://www.acfun.com>
* bilibili <http://www.bilibili.tv>
* bilibili <http://www.bilibili.com>
* CNTV (中国网络电视台) <http://www.cntv.cn>
* Douban (豆瓣) <http://douban.com>
* ifeng (凤凰视频) <http://v.ifeng.com>

View File

@ -43,7 +43,7 @@ Supported Sites (As of Now)
* Tudou (土豆) http://www.tudou.com
* YinYueTai (音悦台) http://www.yinyuetai.com
* AcFun http://www.acfun.com
* bilibili http://www.bilibili.tv
* bilibili http://www.bilibili.com
* CNTV (中国网络电视台) http://www.cntv.cn
* Douban (豆瓣) http://douban.com
* ifeng (凤凰视频) http://v.ifeng.com

View File

@ -11,7 +11,7 @@ from .youku import youku_download_by_id
import re
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)
def parse_srt_p(p):
@ -54,7 +54,7 @@ def parse_cid_playurl(xml):
return urls
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
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)
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)
title = r1(r'<h2[^>]*>([^<>]+)</h2>', html)
title = unescape_html(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
t, id = flashvars.split('=', 1)
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:
x.write(xml)
site_info = "bilibili.tv"
site_info = "bilibili.com"
download = bilibili_download
download_playlist = playlist_not_supported('bilibili')