def bilibili_download(url, merge=True): 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).decode('utf-8') title = unescape_html(title) title = escape_file_path(title) flashvars = r1_of([r'flashvars="([^"]+)"', r'"https://secure.bilibili.tv/secure,(cid=\d+)(?:&aid=\d+)?"'], html) assert flashvars t, id = flashvars.split('=', 1) id = id.split('&')[0] if t == 'cid': bilibili_download_by_cid(id, title, merge=merge) elif t == 'vid': iask_download_by_id(id, title, merge=merge) elif t == 'ykid': youku_download_by_id(id, title, merge=merge) elif t == 'uid': tudou_download_by_id(id, title, merge=merge) else: raise NotImplementedError(flashvars) xml = get_srt_xml(id) with open(title + '.xml', 'w') as x: x.write(xml.encode('utf-8'))
def bilibili_download(url, merge=True): 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).decode('utf-8') title = unescape_html(title) title = escape_file_path(title) flashvars = r1_of([ r'flashvars="([^"]+)"', r'"https://secure.bilibili.tv/secure,(cid=\d+)"' ], html) assert flashvars t, id = flashvars.split('=', 1) if t == 'cid': bilibili_download_by_cid(id, title, merge=merge) elif t == 'vid': iask_download_by_id(id, title, merge=merge) elif t == 'ykid': youku_download_by_id(id, title, merge=merge) elif t == 'uid': tudou_download_by_id(id, title, merge=merge) else: raise NotImplementedError(flashvars) xml = get_srt_xml(id) with open(title + '.xml', 'w') as x: x.write(xml.encode('utf-8'))
def bilibili_download(url): assert re.match(r'http://www.bilibili.tv/video/av(\d+)', url) html = get_html(url) title = r1(r'<h2>([^<>]+)</h2>', html).decode('utf-8') title = unescape_html(title) title = escape_file_path(title) flashvars = r1(r'flashvars="([^"]+)"', html) assert flashvars t, id = flashvars.split('=', 1) if t == 'vid': iask_download_by_id(id, title) elif t == 'ykid': youku_download_by_id(id, title) elif t == 'uid': tudou_download_by_id(id, title) else: raise NotImplementedError(flashvars) xml = get_srt_xml(id) with open(title + '.xml', 'w') as x: x.write(xml.encode('utf-8'))