Example #1
0
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'))
Example #2
0
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'))
Example #3
0
def acfun_download_by_id(id, title):
    info = json.loads(get_html("http://www.acfun.tv/api/getVideoByID.aspx?vid=" + id))
    t = info["vtype"]
    vid = info["vid"]
    if t == "sina":
        iask_download_by_id(vid, title)
    elif t == "youku":
        youku_download_by_id(vid, title)
    elif t == "tudou":
        tudou_download_by_iid(vid, title)
    elif t == "qq":
        qq_download_by_id(vid, title)
    else:
        raise NotImplementedError(t)

    srt = get_srt_json(vid)
    with open(title + ".json", "w") as x:
        x.write(srt)
Example #4
0
def acfun_download_by_id(id, title, merge=True):
	info = json.loads(get_html('http://www.acfun.tv/api/getVideoByID.aspx?vid=' + id))
	t = info['vtype']
	vid = info['vid']
	if t == 'sina':
		iask_download_by_id(vid, title, merge=merge)
	elif t == 'youku':
		youku_download_by_id(vid, title, merge=merge)
	elif t == 'tudou':
		tudou_download_by_iid(vid, title, merge=merge)
	elif t == 'qq':
		qq_download_by_id(vid, title, merge=merge)
	else:
		raise NotImplementedError(t)

	srt = get_srt_json(vid)
	with open(title + '.json', 'w') as x:
		x.write(srt)
Example #5
0
def acfun_download_by_id(id, title, merge=True):
    info = json.loads(
        get_html('http://www.acfun.tv/api/getVideoByID.aspx?vid=' + id))
    t = info['vtype']
    vid = info['vid']
    if t == 'sina':
        iask_download_by_id(vid, title, merge=merge)
    elif t == 'youku':
        youku_download_by_id(vid, title, merge=merge)
    elif t == 'tudou':
        tudou_download_by_iid(vid, title, merge=merge)
    elif t == 'qq':
        qq_download_by_id(vid, title, merge=merge)
    else:
        raise NotImplementedError(t)

    srt = get_srt_json(vid)
    with open(title + '.json', 'w') as x:
        x.write(srt)
Example #6
0
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'))
Example #7
0
def acfun_download(url):
	assert re.match(r'http://www.acfun.tv/v/ac(\d+)', url)
	html = get_html(url).decode('gbk')

	title = r1(r'<title>([^<>]+)</title>', html)
	title = unescape_html(title)
	title = escape_file_path(title)
	title = title.replace(' - AcFun.tv', '')

	flashvars = r1(r'flashvars="([^"]+)"', html)

	t, id = flashvars.split('&amp;id=')
	if t == 'type=video':
		iask_download_by_id(id, title)
	elif t == 'type2=youku':
		youku_download_by_id(id, title)
	elif t == 'type2=tudou':
		tudou_download_by_iid(id, title)
	else:
		raise NotImplementedError(flashvars)

	json = get_srt_json(id)
	with open(title + '.json', 'w') as x:
		x.write(json)