Merge branch 'develop' of https://github.com/soimort/you-get into develop

This commit is contained in:
Valdemar Erk 2017-01-10 12:32:08 +01:00
commit 69a54bfd2c
2 changed files with 22 additions and 17 deletions

View File

@ -73,7 +73,14 @@ def qq_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False):
def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs): def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""""" """"""
if 'live.qq.com' in url: if 'live.qq.com' in url:
qieDownload(url,output_dir=output_dir, merge=merge, info_only=info_only) qieDownload(url, output_dir=output_dir, merge=merge, info_only=info_only)
return
if 'mp.weixin.qq.com/s?' in url:
content = get_html(url)
vids = matchall(content, [r'\bvid=(\w+)'])
for vid in vids:
qq_download_by_vid(vid, vid, output_dir, merge, info_only)
return return
#do redirect #do redirect
@ -101,8 +108,6 @@ def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
title = match1(content, r'"title":"([^"]+)"') if not title else title title = match1(content, r'"title":"([^"]+)"') if not title else title
title = vid if not title else title #general fallback title = vid if not title else title #general fallback
qq_download_by_vid(vid, title, output_dir, merge, info_only) qq_download_by_vid(vid, title, output_dir, merge, info_only)
site_info = "QQ.com" site_info = "QQ.com"

View File

@ -143,9 +143,9 @@ class Youku(VideoExtractor):
}) })
else: else:
proxy_handler = request.ProxyHandler({}) proxy_handler = request.ProxyHandler({})
opener = request.build_opener(ssl_context, cookie_handler, proxy_handler) for handler in (ssl_context, cookie_handler, proxy_handler):
opener.addheaders = [('Cookie','__ysuid={}'.format(time.time()))] request._opener.add_handler(handler)
request.install_opener(opener) request._opener.addheaders = [('Cookie','__ysuid={}'.format(time.time()))]
assert self.url or self.vid assert self.url or self.vid
@ -162,7 +162,7 @@ class Youku(VideoExtractor):
api12_url = kwargs['api12_url'] #86 api12_url = kwargs['api12_url'] #86
self.ctype = kwargs['ctype'] self.ctype = kwargs['ctype']
self.title = kwargs['title'] self.title = kwargs['title']
else: else:
api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=10' % self.vid api_url = 'http://play.youku.com/play/get.json?vid=%s&ct=10' % self.vid
api12_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid api12_url = 'http://play.youku.com/play/get.json?vid=%s&ct=12' % self.vid
@ -330,36 +330,36 @@ class Youku(VideoExtractor):
def open_download_by_vid(self, client_id, vid, **kwargs): def open_download_by_vid(self, client_id, vid, **kwargs):
"""self, str, str, **kwargs->None """self, str, str, **kwargs->None
Arguments: Arguments:
client_id: An ID per client. For now we only know Acfun's client_id: An ID per client. For now we only know Acfun's
such ID. such ID.
vid: An video ID for each video, starts with "C". vid: An video ID for each video, starts with "C".
kwargs['embsig']: Youku COOP's anti hotlinking. kwargs['embsig']: Youku COOP's anti hotlinking.
For Acfun, an API call must be done to Acfun's For Acfun, an API call must be done to Acfun's
server, or the "playsign" of the content of sign_url server, or the "playsign" of the content of sign_url
shall be empty. shall be empty.
Misc: Misc:
Override the original one with VideoExtractor. Override the original one with VideoExtractor.
Author: Author:
Most of the credit are to @ERioK, who gave his POC. Most of the credit are to @ERioK, who gave his POC.
History: History:
Jul.28.2016 Youku COOP now have anti hotlinking via embsig. """ 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_1 = '10ehfkbv' #can be retrived by running r.translate with the keys and the list e
self.f_code_2 = 'msjv7h2b' self.f_code_2 = 'msjv7h2b'
# as in VideoExtractor # as in VideoExtractor
self.url = None self.url = None
self.vid = vid self.vid = vid
self.name = "优酷开放平台 (Youku COOP)" self.name = "优酷开放平台 (Youku COOP)"
#A little bit of work before self.prepare #A little bit of work before self.prepare
#Change as Jul.28.2016 Youku COOP updates its platform to add ant hotlinking #Change as Jul.28.2016 Youku COOP updates its platform to add ant hotlinking
if kwargs['embsig']: 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']) 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'])
@ -371,9 +371,9 @@ class Youku(VideoExtractor):
#to be injected and replace ct10 and 12 #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) 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) 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) self.prepare(api_url = api85_url, api12_url = api86_url, ctype = 86, **kwargs)
#exact copy from original VideoExtractor #exact copy from original VideoExtractor
if 'extractor_proxy' in kwargs and kwargs['extractor_proxy']: if 'extractor_proxy' in kwargs and kwargs['extractor_proxy']:
unset_proxy() unset_proxy()