mirror of
https://github.com/soimort/you-get.git
synced 2025-02-10 12:12:26 +03:00
acfun use old method and fix letvcloud api version update
This commit is contained in:
parent
97f86cb96c
commit
3145e4cd4a
@ -21,37 +21,37 @@ 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_vid(vid, 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://www.acfun.tv/video/getVideo.aspx?id=' + vid))
|
info = json.loads(get_html('http://www.acfun.tv/video/getVideo.aspx?id=' + vid))
|
||||||
# sourceType = info['sourceType']
|
sourceType = info['sourceType']
|
||||||
# sourceId = info['sourceId']
|
sourceId = info['sourceId']
|
||||||
# # danmakuId = info['danmakuId']
|
# danmakuId = info['danmakuId']
|
||||||
# if sourceType == 'sina':
|
if sourceType == 'sina':
|
||||||
# sina_download_by_vid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
sina_download_by_vid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
# elif sourceType == 'youku':
|
elif sourceType == 'youku':
|
||||||
# youku_download_by_vid(sourceId, title=title, output_dir=output_dir, merge=merge, info_only=info_only)
|
youku_download_by_vid(sourceId, title=title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
# elif sourceType == 'tudou':
|
elif sourceType == 'tudou':
|
||||||
# tudou_download_by_iid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
tudou_download_by_iid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
# elif sourceType == 'qq':
|
elif sourceType == 'qq':
|
||||||
# qq_download_by_id(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
qq_download_by_id(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
# elif sourceType == 'letv':
|
elif sourceType == 'letv':
|
||||||
# letvcloud_download_by_vu(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
letvcloud_download_by_vu(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||||
# else:
|
else:
|
||||||
# raise NotImplementedError(sourceType)
|
raise NotImplementedError(sourceType)
|
||||||
|
|
||||||
# if not info_only:
|
if not info_only:
|
||||||
# title = get_filename(title)
|
title = get_filename(title)
|
||||||
# try:
|
try:
|
||||||
# print('Downloading %s ...\n' % (title + '.cmt.json'))
|
print('Downloading %s ...\n' % (title + '.cmt.json'))
|
||||||
# cmt = get_srt_json(vid)
|
cmt = get_srt_json(vid)
|
||||||
# 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 ...\n' % (title + '.cmt_lock.json'))
|
# print('Downloading %s ...\n' % (title + '.cmt_lock.json'))
|
||||||
# # cmt = get_srt_lock_json(danmakuId)
|
# 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:
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -62,52 +62,52 @@ def get_srt_lock_json(id):
|
|||||||
# Sometimes may find C80 but size smaller than C30
|
# Sometimes may find C80 but size smaller than C30
|
||||||
|
|
||||||
|
|
||||||
def acfun_download_by_vid(vid, title=None, output_dir='.', merge=True, info_only=False ,**kwargs):
|
# def acfun_download_by_vid(vid, title=None, output_dir='.', merge=True, info_only=False ,**kwargs):
|
||||||
#api example http://jiexi.acfun.info/index.php?vid=1122870
|
# #api example http://jiexi.acfun.info/index.php?vid=1122870
|
||||||
info = json.loads(get_content("http://jiexi.acfun.info/index.php?vid={}".format(vid)))
|
# info = json.loads(get_content("http://jiexi.acfun.info/index.php?vid={}".format(vid)))
|
||||||
assert info["code"] == 200
|
# assert info["code"] == 200
|
||||||
assert info["success"] == True
|
# assert info["success"] == True
|
||||||
|
|
||||||
support_types = sorted(info["result"].keys(),key= lambda i: int(i[1:]))
|
# support_types = sorted(info["result"].keys(),key= lambda i: int(i[1:]))
|
||||||
|
|
||||||
stream_id = None
|
# stream_id = None
|
||||||
if "stream_id" in kwargs and kwargs["stream_id"] in support_types:
|
# if "stream_id" in kwargs and kwargs["stream_id"] in support_types:
|
||||||
stream_id = kwargs["stream_id"]
|
# stream_id = kwargs["stream_id"]
|
||||||
else:
|
# else:
|
||||||
print("Current Video Supports:")
|
# print("Current Video Supports:")
|
||||||
for i in support_types:
|
# for i in support_types:
|
||||||
if info["result"][i]["totalbytes"] != 0:
|
# if info["result"][i]["totalbytes"] != 0:
|
||||||
print("\t--format",i,"<URL>:",info["result"][i]["quality"],"size:","%.2f"% (info["result"][i]["totalbytes"] / 1024.0 /1024.0),"MB")
|
# print("\t--format",i,"<URL>:",info["result"][i]["quality"],"size:","%.2f"% (info["result"][i]["totalbytes"] / 1024.0 /1024.0),"MB")
|
||||||
else:
|
# else:
|
||||||
print("\t--format",i,"<URL>:",info["result"][i]["quality"])
|
# print("\t--format",i,"<URL>:",info["result"][i]["quality"])
|
||||||
#because C80 is not the best
|
# #because C80 is not the best
|
||||||
if "C80" not in support_types:
|
# if "C80" not in support_types:
|
||||||
stream_id = support_types[-1]
|
# stream_id = support_types[-1]
|
||||||
else:
|
# else:
|
||||||
stream_id = support_types[-2]
|
# stream_id = support_types[-2]
|
||||||
|
|
||||||
urls = [None] * len(info["result"][stream_id]["files"])
|
# urls = [None] * len(info["result"][stream_id]["files"])
|
||||||
for i in info["result"][stream_id]["files"]:
|
# for i in info["result"][stream_id]["files"]:
|
||||||
urls[i["no"]] = i["url"]
|
# urls[i["no"]] = i["url"]
|
||||||
ext = info["result"][stream_id]["files"][0]["type"]
|
# ext = info["result"][stream_id]["files"][0]["type"]
|
||||||
size = 0
|
# size = 0
|
||||||
for i in urls:
|
# for i in urls:
|
||||||
_, _, tmp =url_info(i)
|
# _, _, tmp =url_info(i)
|
||||||
size +=tmp
|
# size +=tmp
|
||||||
print_info(site_info, title, ext, size)
|
# print_info(site_info, title, ext, size)
|
||||||
print("Format: ",stream_id)
|
# print("Format: ",stream_id)
|
||||||
print()
|
# print()
|
||||||
|
|
||||||
if not info_only:
|
# if not info_only:
|
||||||
download_urls(urls, title, ext, size, output_dir = output_dir, merge = merge)
|
# download_urls(urls, title, ext, size, output_dir = output_dir, merge = merge)
|
||||||
title = get_filename(title)
|
# title = get_filename(title)
|
||||||
try:
|
# try:
|
||||||
print('Downloading %s ...\n' % (title + '.cmt.json'))
|
# print('Downloading %s ...\n' % (title + '.cmt.json'))
|
||||||
cmt = get_srt_json(vid)
|
# cmt = get_srt_json(vid)
|
||||||
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)
|
||||||
except:
|
# except:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
def acfun_download(url, output_dir = '.', merge = True, info_only = False ,**kwargs):
|
def acfun_download(url, output_dir = '.', merge = True, info_only = False ,**kwargs):
|
||||||
assert re.match(r'http://[^\.]+.acfun.[^\.]+/\D/\D\D(\d+)', url)
|
assert re.match(r'http://[^\.]+.acfun.[^\.]+/\D/\D\D(\d+)', url)
|
||||||
|
@ -97,10 +97,15 @@ def letv_download_by_vid(vid,title, output_dir='.', merge=True, info_only=False,
|
|||||||
if not info_only:
|
if not info_only:
|
||||||
download_urls(urls, title, ext, size, output_dir=output_dir, merge=merge)
|
download_urls(urls, title, ext, size, output_dir=output_dir, merge=merge)
|
||||||
|
|
||||||
|
#changelog
|
||||||
|
#api ver 2.2
|
||||||
|
# 1.ran -> str(int(time.time()))
|
||||||
|
# 2. key -> 2f9d6924b33a165a6d8b5d3d42f4f987 in bcloud.swf ->binaryData -> com.letv.player.model.EmbedConfig_BIN_CONFIG(xml) -> key ->decode(base64)
|
||||||
def letvcloud_download_by_vu(vu, title=None, output_dir='.', merge=True, info_only=False):
|
def letvcloud_download_by_vu(vu, title=None, output_dir='.', merge=True, info_only=False):
|
||||||
str2Hash = 'cfflashformatjsonran0.7214574650861323uu2d8c027396ver2.1vu' + vu + 'bie^#@(%27eib58'
|
ran= str(int(time.time()))
|
||||||
|
str2Hash = 'cfflashformatjsonran'+ran+'uu2d8c027396ver2.2vu' + vu + '2f9d6924b33a165a6d8b5d3d42f4f987'
|
||||||
sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
|
sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
|
||||||
request_info = urllib.request.Request('http://api.letvcloud.com/gpc.php?&sign='+sign+'&cf=flash&vu='+vu+'&ver=2.1&ran=0.7214574650861323&qr=2&format=json&uu=2d8c027396')
|
request_info = urllib.request.Request('http://api.letvcloud.com/gpc.php?&sign='+sign+'&cf=flash&vu='+vu+'&ver=2.2&ran='+ran+'&qr=2&format=json&uu=2d8c027396')
|
||||||
response = urllib.request.urlopen(request_info)
|
response = urllib.request.urlopen(request_info)
|
||||||
data = response.read()
|
data = response.read()
|
||||||
info = json.loads(data.decode('utf-8'))
|
info = json.loads(data.decode('utf-8'))
|
||||||
|
Loading…
Reference in New Issue
Block a user