mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
AcFun: fix #295
This commit is contained in:
parent
4ab7c50ec8
commit
9fbf298e89
@ -19,29 +19,30 @@ def get_srt_lock_json(id):
|
|||||||
url = 'http://comment.acfun.tv/%s_lock.json' % id
|
url = 'http://comment.acfun.tv/%s_lock.json' % id
|
||||||
return get_html(url)
|
return get_html(url)
|
||||||
|
|
||||||
def acfun_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
|
def acfun_download_by_vid(vid, title=None, output_dir='.', merge=True, info_only=False):
|
||||||
info = json.loads(get_html('http://wenzhou.acfun.tv/api/getVideoByID.aspx?vid=' + id))
|
info = json.loads(get_html('http://www.acfun.tv/video/getVideo.aspx?id=' + vid))
|
||||||
t = info['vtype']
|
sourceType = info['sourceType']
|
||||||
vid = info['vid']
|
sourceId = info['sourceId']
|
||||||
if t == 'sina':
|
danmakuId = info['danmakuId']
|
||||||
sina_download_by_vid(vid, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
if sourceType == 'sina':
|
||||||
elif t == 'youku':
|
sina_download_by_vid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
youku_download_by_id(vid, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
elif sourceType == 'youku':
|
||||||
elif t == 'tudou':
|
youku_download_by_id(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
tudou_download_by_iid(vid, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
elif sourceType == 'tudou':
|
||||||
elif t == 'qq':
|
tudou_download_by_iid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
qq_download_by_id(vid, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
elif sourceType == 'qq':
|
||||||
|
qq_download_by_id(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(t)
|
raise NotImplementedError(t)
|
||||||
|
|
||||||
if not info_only:
|
if not info_only:
|
||||||
try:
|
try:
|
||||||
print('Downloading %s ...' % (title + '.cmt.json'))
|
print('Downloading %s ...' % (title + '.cmt.json'))
|
||||||
cmt = get_srt_json(vid)
|
cmt = get_srt_json(danmakuId)
|
||||||
with open(os.path.join(output_dir, title + '.cmt.json'), 'w') as x:
|
with open(os.path.join(output_dir, title + '.cmt.json'), 'w') as x:
|
||||||
x.write(cmt)
|
x.write(cmt)
|
||||||
print('Downloading %s ...' % (title + '.cmt_lock.json'))
|
print('Downloading %s ...' % (title + '.cmt_lock.json'))
|
||||||
cmt = get_srt_lock_json(vid)
|
cmt = get_srt_lock_json(danmakuId)
|
||||||
with open(os.path.join(output_dir, title + '.cmt_lock.json'), 'w') as x:
|
with open(os.path.join(output_dir, title + '.cmt_lock.json'), 'w') as x:
|
||||||
x.write(cmt)
|
x.write(cmt)
|
||||||
except:
|
except:
|
||||||
@ -50,19 +51,22 @@ def acfun_download_by_id(id, title = None, output_dir = '.', merge = True, info_
|
|||||||
def acfun_download(url, output_dir = '.', merge = True, info_only = False):
|
def acfun_download(url, output_dir = '.', merge = True, info_only = False):
|
||||||
assert re.match(r'http://[^\.]+.acfun.tv/v/ac(\d+)', url)
|
assert re.match(r'http://[^\.]+.acfun.tv/v/ac(\d+)', url)
|
||||||
html = get_html(url)
|
html = get_html(url)
|
||||||
|
|
||||||
title = r1(r'<h1 id="title-article" class="title"[^<>]*>([^<>]+)<', html)
|
title = r1(r'<h1 id="title-article" class="title"[^<>]*>([^<>]+)<', html)
|
||||||
assert title
|
|
||||||
title = unescape_html(title)
|
title = unescape_html(title)
|
||||||
title = escape_file_path(title)
|
title = escape_file_path(title)
|
||||||
title = title.replace(' - AcFun.tv', '')
|
assert title
|
||||||
|
|
||||||
id = r1(r"\[Video\](\d+)\[/Video\]", html) or r1(r"\[video\](\d+)\[/video\]", html)
|
videos = re.findall("data-vid=\"(\d+)\" href=\"[^\"]+\" title=\"([^\"]+)\"", html)
|
||||||
if not id:
|
if videos is not None:
|
||||||
id = r1(r"src=\"/newflvplayer/player.*id=(\d+)", html)
|
for video in videos:
|
||||||
sina_download_by_vid(id, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
p_vid = video[0]
|
||||||
|
p_title = title + " - " + video[1]
|
||||||
|
acfun_download_by_vid(p_vid, p_title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
else:
|
else:
|
||||||
acfun_download_by_id(id, title, output_dir = output_dir, merge = merge, info_only = info_only)
|
# Useless - to be removed?
|
||||||
|
id = r1(r"src=\"/newflvplayer/player.*id=(\d+)", html)
|
||||||
|
sina_download_by_vid(id, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
|
|
||||||
site_info = "AcFun.tv"
|
site_info = "AcFun.tv"
|
||||||
download = acfun_download
|
download = acfun_download
|
||||||
|
Loading…
Reference in New Issue
Block a user