mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 08:43:58 +03:00
Merge pull request #1313 from cnbeining/fix-youku-coop-acfun
[Youku COOP, Acfun]Fix Acfun failed
This commit is contained in:
commit
723df36957
@ -17,10 +17,24 @@ def get_srt_json(id):
|
||||
return get_html(url)
|
||||
|
||||
def acfun_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False, **kwargs):
|
||||
"""str, str, str, bool, bool ->None
|
||||
|
||||
Download Acfun video by vid.
|
||||
|
||||
Call Acfun API, decide which site to use, and pass the job to its
|
||||
extractor.
|
||||
"""
|
||||
|
||||
#first call the main parasing API
|
||||
info = json.loads(get_html('http://www.acfun.tv/video/getVideo.aspx?id=' + vid))
|
||||
|
||||
sourceType = info['sourceType']
|
||||
|
||||
#decide sourceId to know which extractor to use
|
||||
if 'sourceId' in info: sourceId = info['sourceId']
|
||||
# danmakuId = info['danmakuId']
|
||||
|
||||
#call extractor decided by sourceId
|
||||
if sourceType == 'sina':
|
||||
sina_download_by_vid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||
elif sourceType == 'youku':
|
||||
@ -32,11 +46,13 @@ def acfun_download_by_vid(vid, title, output_dir='.', merge=True, info_only=Fals
|
||||
elif sourceType == 'letv':
|
||||
letvcloud_download_by_vu(sourceId, '2d8c027396', title, output_dir=output_dir, merge=merge, info_only=info_only)
|
||||
elif sourceType == 'zhuzhan':
|
||||
#As in Jul.28.2016, Acfun is using embsig to anti hotlink so we need to pass this
|
||||
embsig = info['encode']
|
||||
a = 'http://api.aixifan.com/plays/%s' % vid
|
||||
s = json.loads(get_content(a, headers={'deviceType': '2'}))
|
||||
if s['data']['source'] == "zhuzhan-youku":
|
||||
sourceId = s['data']['sourceId']
|
||||
youku_open_download_by_vid(client_id='908a519d032263f8', vid=sourceId, title=title, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
|
||||
youku_open_download_by_vid(client_id='908a519d032263f8', vid=sourceId, title=title, output_dir=output_dir,merge=merge, info_only=info_only, embsig = embsig, **kwargs)
|
||||
else:
|
||||
raise NotImplementedError(sourceType)
|
||||
|
||||
|
@ -330,22 +330,51 @@ class Youku(VideoExtractor):
|
||||
|
||||
def open_download_by_vid(self, client_id, vid, **kwargs):
|
||||
"""self, str, str, **kwargs->None
|
||||
|
||||
Arguments:
|
||||
client_id: An ID per client. For now we only know Acfun's
|
||||
such ID.
|
||||
|
||||
vid: An video ID for each video, starts with "C".
|
||||
|
||||
kwargs['embsig']: Youku COOP's anti hotlinking.
|
||||
For Acfun, an API call must be done to Acfun's
|
||||
server, or the "playsign" of the content of sign_url
|
||||
shall be empty.
|
||||
|
||||
Misc:
|
||||
Override the original one with VideoExtractor.
|
||||
Most of the credit are to @ERioK, who gave his POC."""
|
||||
|
||||
Author:
|
||||
Most of the credit are to @ERioK, who gave his POC.
|
||||
|
||||
History:
|
||||
Jul.28.2016 Youku COOP now have anti hotlinking via embsig. """
|
||||
self.f_code_1 = '10ehfkbv' #can be retrived by running r.translate with the keys and the list e
|
||||
self.f_code_2 = 'msjv7h2b'
|
||||
|
||||
# as in VideoExtractor
|
||||
self.url = None
|
||||
self.vid = vid
|
||||
self.name = "优酷开放平台 (Youku COOP)"
|
||||
|
||||
#A little bit of work before self.prepare
|
||||
|
||||
#Change as Jul.28.2016 Youku COOP updates its platform to add ant hotlinking
|
||||
if kwargs['embsig']:
|
||||
sign_url = "https://api.youku.com/players/custom.json?client_id={client_id}&video_id={video_id}&embsig={embsig}".format(client_id = client_id, video_id = vid, embsig = kwargs['embsig'])
|
||||
else:
|
||||
sign_url = "https://api.youku.com/players/custom.json?client_id={client_id}&video_id={video_id}".format(client_id = client_id, video_id = vid)
|
||||
|
||||
playsign = json.loads(get_content(sign_url))['playsign']
|
||||
|
||||
#to be injected and replace ct10 and 12
|
||||
api85_url = 'http://play.youku.com/partner/get.json?cid={client_id}&vid={vid}&ct=85&sign={playsign}'.format(client_id = client_id, vid = vid, playsign = playsign)
|
||||
api86_url = 'http://play.youku.com/partner/get.json?cid={client_id}&vid={vid}&ct=86&sign={playsign}'.format(client_id = client_id, vid = vid, playsign = playsign)
|
||||
|
||||
self.prepare(api_url = api85_url, api12_url = api86_url, ctype = 86, **kwargs)
|
||||
|
||||
#exact copy from original VideoExtractor
|
||||
if 'extractor_proxy' in kwargs and kwargs['extractor_proxy']:
|
||||
unset_proxy()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user