From 37dbb4a3ce4d0ce1b3216ac867ddc704bea5ca32 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Mon, 27 Feb 2017 00:29:45 -0500 Subject: [PATCH 01/32] [common] print user agent when dumping URLs (-u, --url) Certain sites (known example: tudou.com) deny access to video URLs unless user agent matches the one used when retrieving URLs from the API, effectively rendering the URLs useless without the proper user agent. Therefore, exposing the user agent in -u, --url output could come in handy at times. This commit does not affect --json output. --- src/you_get/common.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/you_get/common.py b/src/you_get/common.py index 2edbc426..b1666f22 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -751,12 +751,18 @@ def get_output_filename(urls, title, ext, output_dir, merge): merged_ext = 'ts' return '%s.%s' % (title, merged_ext) +def print_user_agent(faker=False): + urllib_default_user_agent = 'Python-urllib/%d.%d' % sys.version_info[:2] + user_agent = fake_headers['User-Agent'] if faker else urllib_default_user_agent + print('User Agent: %s' % user_agent) + def download_urls(urls, title, ext, total_size, output_dir='.', refer=None, merge=True, faker=False, headers = {}, **kwargs): assert urls if json_output: json_output_.download_urls(urls=urls, title=title, ext=ext, total_size=total_size, refer=refer) return if dry_run: + print_user_agent(faker=faker) print('Real URLs:\n%s' % '\n'.join(urls)) return @@ -873,6 +879,7 @@ def download_urls(urls, title, ext, total_size, output_dir='.', refer=None, merg def download_urls_chunked(urls, title, ext, total_size, output_dir='.', refer=None, merge=True, faker=False, headers = {}, **kwargs): assert urls if dry_run: + print_user_agent(faker=faker) print('Real URLs:\n%s\n' % urls) return @@ -952,6 +959,7 @@ def download_urls_chunked(urls, title, ext, total_size, output_dir='.', refer=No def download_rtmp_url(url,title, ext,params={}, total_size=0, output_dir='.', refer=None, merge=True, faker=False): assert url if dry_run: + print_user_agent(faker=faker) print('Real URL:\n%s\n' % [url]) if params.get("-y",False): #None or unset ->False print('Real Playpath:\n%s\n' % [params.get("-y")]) @@ -969,6 +977,7 @@ def download_rtmp_url(url,title, ext,params={}, total_size=0, output_dir='.', re def download_url_ffmpeg(url,title, ext,params={}, total_size=0, output_dir='.', refer=None, merge=True, faker=False): assert url if dry_run: + print_user_agent(faker=faker) print('Real URL:\n%s\n' % [url]) if params.get("-y",False): #None or unset ->False print('Real Playpath:\n%s\n' % [params.get("-y")]) From 6fa81497d539a99fda2636126df3e485179a4edd Mon Sep 17 00:00:00 2001 From: MaxwellGoblin Date: Thu, 20 Jul 2017 17:14:05 +0800 Subject: [PATCH 02/32] [youtube]use mp4_audio track when no audio track for webm --- src/you_get/extractors/youtube.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py index 986906d6..3b412dc2 100644 --- a/src/you_get/extractors/youtube.py +++ b/src/you_get/extractors/youtube.py @@ -366,14 +366,22 @@ class YouTube(VideoExtractor): dash_url += '&signature={}'.format(sig) dash_size = stream['clen'] itag = stream['itag'] + audio_url = None + audio_size = None + try: + audio_url = dash_webm_a_url + audio_size = int(dash_webm_a_size) + except UnboundLocalError as e: + audio_url = dash_mp4_a_url + audio_size = int(dash_mp4_a_size) self.dash_streams[itag] = { 'quality': stream['size'], 'itag': itag, 'type': mimeType, 'mime': mimeType, 'container': 'webm', - 'src': [dash_url, dash_webm_a_url], - 'size': int(dash_size) + int(dash_webm_a_size) + 'src': [dash_url, audio_url], + 'size': int(dash_size) + int(audio_size) } def extract(self, **kwargs): From 3d08064d315949bff6ec014a059ad889a248adf1 Mon Sep 17 00:00:00 2001 From: Hongbo Liu Date: Thu, 4 Jan 2018 23:34:20 +0800 Subject: [PATCH 03/32] [qq] fix weixin embedded video support --- src/you_get/extractors/qq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/qq.py b/src/you_get/extractors/qq.py index 438c1f24..89dd7b61 100644 --- a/src/you_get/extractors/qq.py +++ b/src/you_get/extractors/qq.py @@ -114,7 +114,7 @@ def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs): qieDownload(url, output_dir=output_dir, merge=merge, info_only=info_only) return - if 'mp.weixin.qq.com/s?' in url: + if 'mp.weixin.qq.com/s' in url: content = get_content(url) vids = matchall(content, [r'\?vid=(\w+)']) for vid in vids: From 68a0e9c4b0120cfa309d1959d74f4cc0685d5ab0 Mon Sep 17 00:00:00 2001 From: ygmpkk Date: Fri, 5 Jan 2018 12:23:02 +0800 Subject: [PATCH 04/32] fix http code 403 and 466 error for bilibili --- src/you_get/extractors/bilibili.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index 09e08ecb..1ec41203 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -68,7 +68,7 @@ class Bilibili(VideoExtractor): chksum = hashlib.md5(bytes(params_str+self.SEC2, 'utf8')).hexdigest() api_url = self.bangumi_api_url + params_str + '&sign=' + chksum - xml_str = get_content(api_url) + xml_str = get_content(api_url, headers={'referer': self.url, 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'}) return xml_str def parse_bili_xml(self, xml_str): From a345635473c9b2c2a1cb122f16bad4fae734f4c7 Mon Sep 17 00:00:00 2001 From: 9yw <25059561+9yw@users.noreply.github.com> Date: Wed, 10 Jan 2018 15:32:40 +0800 Subject: [PATCH 05/32] Update youku.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ccode=0512会报错 客户端无权播放,201 改成5013可以下载 --- src/you_get/extractors/youku.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index 976ed447..9d74b9c8 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -78,7 +78,7 @@ class Youku(VideoExtractor): self.api_error_code = None self.api_error_msg = None - self.ccode = '0512' + self.ccode = '0513' self.utid = None def youku_ups(self): From e8385913d91ba7b996bae19eb7623be0c3c7b36a Mon Sep 17 00:00:00 2001 From: Justsoos Date: Thu, 25 Jan 2018 23:37:46 +0800 Subject: [PATCH 06/32] update douyutv.py for room_id bugs m.douyu.com DOES have the unique room_id, for counter-example: https://www.douyu.com/aleng1106, there is no room_id in this page --- src/you_get/extractors/douyutv.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/douyutv.py b/src/you_get/extractors/douyutv.py index 3b64066a..4bd0e14c 100644 --- a/src/you_get/extractors/douyutv.py +++ b/src/you_get/extractors/douyutv.py @@ -43,8 +43,10 @@ def douyutv_download(url, output_dir = '.', merge = True, info_only = False, **k headers = { 'user-agent': 'Mozilla/5.0 (iPad; CPU OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B466 Safari/600.1.4' } + + url = re.sub(r'[w.]*douyu.com','m.douyu.com',url) html = get_content(url, headers) - room_id_patt = r'"room_id"\s*:\s*(\d+),' + room_id_patt = r'room_id\s*:\s*(\d+),' room_id = match1(html, room_id_patt) if room_id == "0": room_id = url[url.rfind('/')+1:] From 34b51cbecb7e5044580ccb3458ceaf0b99c5959a Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Fri, 2 Feb 2018 19:01:39 +0100 Subject: [PATCH 07/32] [bilibili] fix some title regexes --- src/you_get/extractors/bilibili.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index 1ec41203..ab19c41c 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -125,11 +125,11 @@ class Bilibili(VideoExtractor): self.referer = self.url self.page = get_content(self.url) - m = re.search(r'(.*?)', self.page) + m = re.search(r'(.*?)', self.page) or re.search(r'

', self.page) if m is not None: self.title = m.group(1) if self.title is None: - m = re.search(r'', self.page) + m = re.search(r'property="og:title" content="([^"]+)"', self.page) if m is not None: self.title = m.group(1) if 'subtitle' in kwargs: From 38737c40f1541987b0c508803b75e1a12f8a5196 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sat, 3 Feb 2018 17:57:04 +0100 Subject: [PATCH 08/32] [test] remove test_yixia --- tests/test.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test.py b/tests/test.py index 699675f3..6562d7ca 100644 --- a/tests/test.py +++ b/tests/test.py @@ -6,9 +6,7 @@ from you_get.extractors import ( imgur, magisto, youtube, - yixia, bilibili, - douyin, ) @@ -33,12 +31,6 @@ class YouGetTests(unittest.TestCase): info_only=True ) - def test_yixia(self): - yixia.download( - 'http://m.miaopai.com/show/channel/vlvreCo4OZiNdk5Jn1WvdopmAvdIJwi8', # noqa - info_only=True - ) - def test_bilibili(self): bilibili.download( 'https://www.bilibili.com/video/av16907446/', info_only=True From ea0bf8c32a212205752f067d1dd06593a280b9f7 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Fri, 9 Feb 2018 15:50:09 +0100 Subject: [PATCH 09/32] version 0.4.1025 --- src/you_get/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/version.py b/src/you_get/version.py index e4420b84..2d4ff9d0 100644 --- a/src/you_get/version.py +++ b/src/you_get/version.py @@ -1,4 +1,4 @@ #!/usr/bin/env python script_name = 'you-get' -__version__ = '0.4.1011' +__version__ = '0.4.1025' From 6bac1cd5dc2540ed140b03f3ea96e0cbe7add2f1 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Fri, 9 Feb 2018 15:53:04 -0700 Subject: [PATCH 10/32] bilibili: adapt to new bangumi API --- src/you_get/extractors/bilibili.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index ab19c41c..e5abccab 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -140,6 +140,8 @@ class Bilibili(VideoExtractor): self.movie_entry(**kwargs) elif 'bangumi.bilibili.com' in self.url: self.bangumi_entry(**kwargs) + elif 'bangumi/' in self.url: + self.bangumi_entry(**kwargs) elif 'live.bilibili.com' in self.url: self.live_entry(**kwargs) elif 'vc.bilibili.com' in self.url: @@ -235,22 +237,22 @@ class Bilibili(VideoExtractor): def bangumi_entry(self, **kwargs): bangumi_id = re.search(r'(\d+)', self.url).group(1) - bangumi_data = get_bangumi_info(bangumi_id) - bangumi_payment = bangumi_data.get('payment') - if bangumi_payment and bangumi_payment['price'] != '0': - log.w("It's a paid item") - # ep_ids = collect_bangumi_epids(bangumi_data) - frag = urllib.parse.urlparse(self.url).fragment if frag: episode_id = frag else: - episode_id = re.search(r'first_ep_id\s*=\s*"(\d+)"', self.page) + episode_id = re.search(r'first_ep_id\s*=\s*"(\d+)"', self.page) or re.search(r'\/ep(\d+)', self.url).group(1) # cont = post_content('http://bangumi.bilibili.com/web_api/get_source', post_data=dict(episode_id=episode_id)) # cid = json.loads(cont)['result']['cid'] cont = get_content('http://bangumi.bilibili.com/web_api/episode/{}.json'.format(episode_id)) ep_info = json.loads(cont)['result']['currentEpisode'] + bangumi_data = get_bangumi_info(str(ep_info['seasonId'])) + bangumi_payment = bangumi_data.get('payment') + if bangumi_payment and bangumi_payment['price'] != '0': + log.w("It's a paid item") + # ep_ids = collect_bangumi_epids(bangumi_data) + index_title = ep_info['indexTitle'] long_title = ep_info['longTitle'].strip() cid = ep_info['danmaku'] @@ -295,10 +297,10 @@ def collect_bangumi_epids(json_data): eps = json_data['episodes'][::-1] return [ep['episode_id'] for ep in eps] -def get_bangumi_info(bangumi_id): +def get_bangumi_info(season_id): BASE_URL = 'http://bangumi.bilibili.com/jsonp/seasoninfo/' long_epoch = int(time.time() * 1000) - req_url = BASE_URL + bangumi_id + '.ver?callback=seasonListCallback&jsonp=jsonp&_=' + str(long_epoch) + req_url = BASE_URL + season_id + '.ver?callback=seasonListCallback&jsonp=jsonp&_=' + str(long_epoch) season_data = get_content(req_url) season_data = season_data[len('seasonListCallback('):] season_data = season_data[: -1 * len(');')] From 0ed54eea3f3924f15b68bb81bbe4c7b6149e21c8 Mon Sep 17 00:00:00 2001 From: Justsoos Date: Mon, 12 Feb 2018 01:15:57 +0800 Subject: [PATCH 11/32] Parameter type error #you-get -du https://www.douyu.com/lpl [DEBUG] get_content: https://m.douyu.com/lpl ... Traceback (most recent call last): ... File "/usr/local/lib/python3.5/dist-packages/you_get/common.py", line 1574, in any_download m.download(url, **kwargs) File "/usr/local/lib/python3.5/dist-packages/you_get/extractors/douyutv.py", line 81, in douyutv_download download_url_ffmpeg(real_url, title, 'flv', None, output_dir = output_dir, merge = merge) File "/usr/local/lib/python3.5/dist-packages/you_get/common.py", line 1013, in download_url_ffmpeg if params.get('-y', False): # None or unset ->False AttributeError: 'NoneType' object has no attribute 'get' --- src/you_get/extractors/douyutv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/douyutv.py b/src/you_get/extractors/douyutv.py index 4bd0e14c..b7b15e74 100644 --- a/src/you_get/extractors/douyutv.py +++ b/src/you_get/extractors/douyutv.py @@ -73,7 +73,7 @@ def douyutv_download(url, output_dir = '.', merge = True, info_only = False, **k print_info(site_info, title, 'flv', float('inf')) if not info_only: - download_url_ffmpeg(real_url, title, 'flv', None, output_dir = output_dir, merge = merge) + download_url_ffmpeg(real_url, title, 'flv', params={}, output_dir = output_dir, merge = merge) site_info = "douyu.com" download = douyutv_download From 0b8731cbc743361706aab269f5c1e1a7991447d9 Mon Sep 17 00:00:00 2001 From: Justsoos Date: Tue, 13 Feb 2018 03:46:43 +0800 Subject: [PATCH 12/32] Update quanmin.py api changed, and no need of import time --- src/you_get/extractors/quanmin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/quanmin.py b/src/you_get/extractors/quanmin.py index bf1af659..7428d1cb 100644 --- a/src/you_get/extractors/quanmin.py +++ b/src/you_get/extractors/quanmin.py @@ -4,7 +4,6 @@ __all__ = ['quanmin_download'] from ..common import * import json -import time def quanmin_download(url, output_dir = '.', merge = True, info_only = False, **kwargs): roomid = url.split('/')[3].split('?')[0] @@ -17,7 +16,8 @@ def quanmin_download(url, output_dir = '.', merge = True, info_only = False, **k if not data["play_status"]: raise ValueError("The live stream is not online!") - real_url = "http://flv.quanmin.tv/live/{}.flv".format(roomid) + + real_url = data["live"]["ws"]["flv"]["5"]["src"] print_info(site_info, title, 'flv', float('inf')) if not info_only: From f6be4a2904b3b1451b1c02f2f58a05b3f789d8f6 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 15 Feb 2018 21:30:31 +0100 Subject: [PATCH 13/32] [acfun] update API --- src/you_get/extractors/acfun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/acfun.py b/src/you_get/extractors/acfun.py index a5ea7659..c521422f 100644 --- a/src/you_get/extractors/acfun.py +++ b/src/you_get/extractors/acfun.py @@ -49,7 +49,7 @@ def acfun_download_by_vid(vid, title, output_dir='.', merge=True, info_only=Fals """ #first call the main parasing API - info = json.loads(get_content('http://www.acfun.tv/video/getVideo.aspx?id=' + vid)) + info = json.loads(get_content('http://www.acfun.cn/video/getVideo.aspx?id=' + vid)) sourceType = info['sourceType'] From 739504e988541216ebfc6529b12ed1d3300807ee Mon Sep 17 00:00:00 2001 From: Kugelblitz <21170940+Kugel-Blitz@users.noreply.github.com> Date: Sun, 18 Feb 2018 11:08:17 +1300 Subject: [PATCH 14/32] Change code to 0507 `mp4hd3` format of some videos cannot be extracted with 0513, but can be extracted with 0507. --- src/you_get/extractors/youku.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index 9d74b9c8..099552cf 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -78,7 +78,7 @@ class Youku(VideoExtractor): self.api_error_code = None self.api_error_msg = None - self.ccode = '0513' + self.ccode = '0507' self.utid = None def youku_ups(self): From 3ce35a86f089f15ef5df88c494ffd75a62c256a4 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 18 Feb 2018 00:38:00 +0100 Subject: [PATCH 15/32] [yixia] make things right --- src/you_get/extractors/yixia.py | 34 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/you_get/extractors/yixia.py b/src/you_get/extractors/yixia.py index a37c359c..ccaaf546 100644 --- a/src/you_get/extractors/yixia.py +++ b/src/you_get/extractors/yixia.py @@ -11,14 +11,14 @@ import re def yixia_miaopai_download_by_scid(scid, output_dir = '.', merge = True, info_only = False): """""" api_endpoint = 'http://api.miaopai.com/m/v2_channel.json?fillType=259&scid={scid}&vend=miaopai'.format(scid = scid) - + html = get_content(api_endpoint) - + api_content = loads(html) - + video_url = match1(api_content['result']['stream']['base'], r'(.+)\?vend') title = api_content['result']['ext']['t'] - + type, ext, size = url_info(video_url) print_info(site_info, title, type, size) @@ -29,14 +29,14 @@ def yixia_miaopai_download_by_scid(scid, output_dir = '.', merge = True, info_on def yixia_xiaokaxiu_download_by_scid(scid, output_dir = '.', merge = True, info_only = False): """""" api_endpoint = 'http://api.xiaokaxiu.com/video/web/get_play_video?scid={scid}'.format(scid = scid) - + html = get_content(api_endpoint) - + api_content = loads(html) - + video_url = api_content['data']['linkurl'] title = api_content['data']['title'] - + type, ext, size = url_info(video_url) print_info(site_info, title, type, size) @@ -50,20 +50,16 @@ def yixia_download(url, output_dir = '.', merge = True, info_only = False, **kwa if 'miaopai.com' in hostname: #Miaopai yixia_download_by_scid = yixia_miaopai_download_by_scid site_info = "Yixia Miaopai" - - if re.match(r'https?://www.miaopai.com/show/channel/.+', url): #PC - scid = match1(url, r'https?://www.miaopai.com/show/channel/(.+)\.htm') - elif re.match(r'https?://www.miaopai.com/show/.+', url): #PC - scid = match1(url, r'https?://www.miaopai.com/show/(.+)\.htm') - elif re.match(r'https?://m.miaopai.com/show/channel/.+', url): #Mobile - scid = match1(url, r'https?://m.miaopai.com/show/channel/(.+)\.htm') - if scid == None : - scid = match1(url, r'https?://m.miaopai.com/show/channel/(.+)') + + scid = match1(url, r'miaopai\.com/show/channel/(.+)\.htm') or \ + match1(url, r'miaopai\.com/show/(.+)\.htm') or \ + match1(url, r'm\.miaopai\.com/show/channel/(.+)\.htm') or \ + match1(url, r'm\.miaopai\.com/show/channel/(.+)') elif 'xiaokaxiu.com' in hostname: #Xiaokaxiu yixia_download_by_scid = yixia_xiaokaxiu_download_by_scid site_info = "Yixia Xiaokaxiu" - + if re.match(r'http://v.xiaokaxiu.com/v/.+\.html', url): #PC scid = match1(url, r'http://v.xiaokaxiu.com/v/(.+)\.html') elif re.match(r'http://m.xiaokaxiu.com/m/.+\.html', url): #Mobile @@ -71,7 +67,7 @@ def yixia_download(url, output_dir = '.', merge = True, info_only = False, **kwa else: pass - + yixia_download_by_scid(scid, output_dir, merge, info_only) site_info = "Yixia" From 6e38f28474984faa070da24633c484cf98198032 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 18 Feb 2018 00:52:35 +0100 Subject: [PATCH 16/32] [twitter] normalize mobile URL --- src/you_get/extractors/twitter.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/you_get/extractors/twitter.py b/src/you_get/extractors/twitter.py index 04fd8773..9c5acb31 100644 --- a/src/you_get/extractors/twitter.py +++ b/src/you_get/extractors/twitter.py @@ -15,6 +15,9 @@ def extract_m3u(source): return ['https://video.twimg.com%s' % i for i in s2] def twitter_download(url, output_dir='.', merge=True, info_only=False, **kwargs): + if re.match(r'https?://mobile', url): # normalize mobile URL + url = 'https://' + match1(url, r'//mobile\.(.+)') + html = get_html(url) screen_name = r1(r'data-screen-name="([^"]*)"', html) or \ r1(r' Date: Mon, 19 Feb 2018 22:00:55 +0800 Subject: [PATCH 17/32] Add longzhu.com --- src/you_get/common.py | 1 + src/you_get/extractors/__init__.py | 1 + src/you_get/extractors/longzhu.py | 73 ++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 src/you_get/extractors/longzhu.py diff --git a/src/you_get/common.py b/src/you_get/common.py index a4a036a4..4ea144f1 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -74,6 +74,7 @@ SITES = { 'le' : 'le', 'letv' : 'le', 'lizhi' : 'lizhi', + 'longzhu' : 'longzhu', 'magisto' : 'magisto', 'metacafe' : 'metacafe', 'mgtv' : 'mgtv', diff --git a/src/you_get/extractors/__init__.py b/src/you_get/extractors/__init__.py index 46e5c89c..ec9e86ae 100755 --- a/src/you_get/extractors/__init__.py +++ b/src/you_get/extractors/__init__.py @@ -41,6 +41,7 @@ from .kugou import * from .kuwo import * from .le import * from .lizhi import * +from .longzhu import * from .magisto import * from .metacafe import * from .mgtv import * diff --git a/src/you_get/extractors/longzhu.py b/src/you_get/extractors/longzhu.py new file mode 100644 index 00000000..ed0cb084 --- /dev/null +++ b/src/you_get/extractors/longzhu.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +__all__ = ['longzhu_download'] + +import json +from ..common import ( + get_content, + match1, + print_info, + download_urls, + playlist_not_supported, +) +from ..common import player + +def longzhu_download(url, output_dir = '.', merge=True, info_only=False, **kwargs): + web_domain = url.split('/')[2] + if (web_domain == 'star.longzhu.com') or (web_domain == 'y.longzhu.com'): + domain = url.split('/')[3].split('?')[0] + m_url = 'http://m.longzhu.com/{0}'.format(domain) + m_html = get_content(m_url) + room_id_patt = r'var\s*roomId\s*=\s*(\d+);' + room_id = match1(m_html,room_id_patt) + + json_url = 'http://liveapi.plu.cn/liveapp/roomstatus?roomId={0}'.format(room_id) + content = get_content(json_url) + data = json.loads(content) + streamUri = data['streamUri'] + if len(streamUri) <= 4: + raise ValueError('The live stream is not online!') + title = data['title'] + streamer = data['userName'] + title = str.format(streamer,': ',title) + + steam_api_url = 'http://livestream.plu.cn/live/getlivePlayurl?roomId={0}'.format(room_id) + content = get_content(steam_api_url) + data = json.loads(content) + isonline = data.get('isTransfer') + if isonline == '0': + raise ValueError('The live stream is not online!') + + real_url = data['playLines'][0]['urls'][0]['securityUrl'] + + print_info(site_info, title, 'flv', float('inf')) + + if not info_only: + download_urls([real_url], title, 'flv', None, output_dir, merge=merge) + + elif web_domain == 'replay.longzhu.com': + videoid = match1(url, r'(\d+)$') + json_url = 'http://liveapi.longzhu.com/livereplay/getreplayfordisplay?videoId={0}'.format(videoid) + content = get_content(json_url) + data = json.loads(content) + + username = data['userName'] + title = data['title'] + title = str.format(username,':',title) + real_url = data['videoUrl'] + + if player: + print_info('Longzhu Video', title, 'm3u8', 0) + download_urls([real_url], title, 'm3u8', 0, output_dir, merge=merge) + else: + urls = general_m3u8_extractor(real_url) + print_info('Longzhu Video', title, 'm3u8', 0) + if not info_only: + download_urls(urls, title, 'ts', 0, output_dir=output_dir, merge=merge, **kwargs) + + else: + raise ValueError('Wrong url or unsupported link ... {0}'.format(url)) + +site_info = 'longzhu.com' +download = longzhu_download +download_playlist = playlist_not_supported('longzhu') \ No newline at end of file From a22dce896cd13ca398f748b93c73ea172b837df1 Mon Sep 17 00:00:00 2001 From: John128217 <35967907+John128217@users.noreply.github.com> Date: Wed, 21 Feb 2018 14:23:21 -0800 Subject: [PATCH 18/32] Added an auto rename option and fixed the force option I've noticed that if I am downloading two videos with same names from youtube (e.g. https://www.youtube.com/watch?v=606hmlA_nxw and https://www.youtube.com/watch?v=CLrXTnggUeY), only one of them will be saved (usually the bigger one according to the original script "os.path.getsize(output_filepath) >= total_size * 0.9"). However, I want them both while preserving their names from youtube. So I modified the source code. It looks like there are a lot of changes, but I just added an indent and everything changed. Also, I've noticed that "force" is not working at all. I fixed that issue. --- src/you_get/common.py | 63 +++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index a4a036a4..76cf5b97 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -134,6 +134,7 @@ player = None extractor_proxy = None cookies = None output_filename = None +auto_rename = False fake_headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', # noqa @@ -598,27 +599,40 @@ def url_save( tmp_headers['Referer'] = refer file_size = url_size(url, faker=faker, headers=tmp_headers) - if os.path.exists(filepath): - if not force and file_size == os.path.getsize(filepath): - if not is_part: - if bar: - bar.done() - print( - 'Skipping {}: file already exists'.format( - tr(os.path.basename(filepath)) + continue_renameing = True + while continue_renameing: + continue_renameing = False + if os.path.exists(filepath): + if not force and file_size == os.path.getsize(filepath): + if not is_part: + if bar: + bar.done() + print( + 'Skipping {}: file already exists'.format( + tr(os.path.basename(filepath)) + ) ) - ) + else: + if bar: + bar.update_received(file_size) + return else: - if bar: - bar.update_received(file_size) - return - else: - if not is_part: - if bar: - bar.done() - print('Overwriting %s' % tr(os.path.basename(filepath)), '...') - elif not os.path.exists(os.path.dirname(filepath)): - os.mkdir(os.path.dirname(filepath)) + if not is_part: + if bar: + bar.done() + if not force and auto_rename: + path, ext = os.path.basename(filepath).rsplit('.', 1) + if (re.compile(' \(\d\)').match(path[-4:]) is None): + thisfile = path + ' (1).' + ext + else: + thisfile = path[:-2] + str(int(path[-2]) + 1) + ').' + ext + filepath = os.path.join(os.path.dirname(filepath), thisfile) + print('Changing name to %s' % tr(os.path.basename(filepath)), '...') + continue_renameing = True + continue + print('Overwriting %s' % tr(os.path.basename(filepath)), '...') + elif not os.path.exists(os.path.dirname(filepath)): + os.mkdir(os.path.dirname(filepath)) temp_filepath = filepath + '.download' if file_size != float('inf') \ else filepath @@ -883,7 +897,7 @@ def download_urls( output_filepath = os.path.join(output_dir, output_filename) if total_size: - if not force and os.path.exists(output_filepath) \ + if not force and os.path.exists(output_filepath) and not auto_rename\ and os.path.getsize(output_filepath) >= total_size * 0.9: print('Skipping %s: file already exists' % output_filepath) print() @@ -1370,6 +1384,10 @@ def script_main(download, download_playlist, **kwargs): '-l', '--playlist', action='store_true', help='Prefer to download a playlist' ) + download_grp.add_argument( + '-a', '--auto-rename', action='store_true', default=False, + help='Auto rename same name different files' + ) proxy_grp = parser.add_argument_group('Proxy options') proxy_grp = proxy_grp.add_mutually_exclusive_group() @@ -1414,11 +1432,16 @@ def script_main(download, download_playlist, **kwargs): global player global extractor_proxy global output_filename + global auto_rename output_filename = args.output_filename extractor_proxy = args.extractor_proxy info_only = args.info + if args.force: + force = True + if args.auto_rename: + auto_rename = True if args.url: dry_run = True if args.json: From c7290c7c2fa5bbf9c4623cf5694b742212d74df7 Mon Sep 17 00:00:00 2001 From: John128217 <35967907+John128217@users.noreply.github.com> Date: Wed, 21 Feb 2018 21:55:28 -0800 Subject: [PATCH 19/32] A number bug fixed Now if you can have more than 10 videos that have same names. --- src/you_get/common.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index 76cf5b97..0d1b1810 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -622,10 +622,13 @@ def url_save( bar.done() if not force and auto_rename: path, ext = os.path.basename(filepath).rsplit('.', 1) - if (re.compile(' \(\d\)').match(path[-4:]) is None): + finder = re.compile(' \([1-9]\d*?\)$') + if (finder.search(path) is None): thisfile = path + ' (1).' + ext else: - thisfile = path[:-2] + str(int(path[-2]) + 1) + ').' + ext + def numreturn(a): + return ' (' + str(int(a.group()[2:-1]) + 1) + ').' + thisfile = finder.sub(numreturn, path) + ext filepath = os.path.join(os.path.dirname(filepath), thisfile) print('Changing name to %s' % tr(os.path.basename(filepath)), '...') continue_renameing = True From b4850f5a5907a263d36d7d78e231f86e2321bd4c Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 22 Feb 2018 17:21:43 +0100 Subject: [PATCH 20/32] [common] indent! --- src/you_get/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index 4ea144f1..b4d57841 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -74,7 +74,7 @@ SITES = { 'le' : 'le', 'letv' : 'le', 'lizhi' : 'lizhi', - 'longzhu' : 'longzhu', + 'longzhu' : 'longzhu', 'magisto' : 'magisto', 'metacafe' : 'metacafe', 'mgtv' : 'mgtv', From 0b50fdfab430cff3b1e02c17def260ae0a5b47a3 Mon Sep 17 00:00:00 2001 From: perror <15058342792@163.com> Date: Wed, 28 Feb 2018 16:45:48 +0800 Subject: [PATCH 21/32] [ixigua] fix URL request error and video download error and video encryption parameters acquisition --- src/you_get/extractors/ixigua.py | 40 ++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/you_get/extractors/ixigua.py b/src/you_get/extractors/ixigua.py index aaed195d..0c668e82 100644 --- a/src/you_get/extractors/ixigua.py +++ b/src/you_get/extractors/ixigua.py @@ -5,30 +5,35 @@ import random import binascii from ..common import * -def get_video_id(text): - re_id = r"videoId: '(.*?)'" - return re.findall(re_id, text)[0] +headers = { + 'User-Agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36' + ' (KHTML, like Gecko) Chrome/61.0.3163.100 Mobile Safari/537.36' +} + def get_r(): return str(random.random())[2:] + def right_shift(val, n): return val >> n if val >= 0 else (val + 0x100000000) >> n + def get_s(text): """get video info""" - id = get_video_id(text) + js_data = json.loads(text) + id = js_data['data']['video_id'] p = get_r() url = 'http://i.snssdk.com/video/urls/v/1/toutiao/mp4/%s' % id n = parse.urlparse(url).path + '?r=%s' % p c = binascii.crc32(n.encode('utf-8')) s = right_shift(c, 0) - title = ''.join(re.findall(r"title: '(.*?)',", text)) - return url + '?r=%s&s=%s' % (p, s), title + return url + '?r=%s&s=%s' % (p, s), js_data['data']['title'] + def get_moment(url, user_id, base_url, video_list): """Recursively obtaining a video list""" - video_list_data = json.loads(get_content(url)) + video_list_data = json.loads(get_content(url, headers=headers)) if not video_list_data['next']['max_behot_time']: return video_list [video_list.append(i["display_url"]) for i in video_list_data["data"]] @@ -41,23 +46,33 @@ def get_moment(url, user_id, base_url, video_list): } return get_moment(**_param) + def ixigua_download(url, output_dir='.', info_only=False, **kwargs): """ Download a single video Sample URL: https://www.ixigua.com/a6487187567887254029/#mid=59051127876 """ try: - video_info_url, title = get_s(get_content(url)) - video_info = json.loads(get_content(video_info_url)) + video_page_id = re.findall('(\d+)', [i for i in url.split('/') if i][3])[0] if 'toutiao.com' in url \ + else re.findall('(\d+)', [i for i in url.split('/') if i][2])[0] + + video_start_info_url = r'https://m.ixigua.com/i{}/info/'.format(video_page_id) + video_info_url, title = get_s(get_content(video_start_info_url, headers=headers or kwargs.get('headers', {}))) + video_info = json.loads(get_content(video_info_url, headers=headers or kwargs.get('headers', {}))) except Exception: raise NotImplementedError(url) try: video_url = base64.b64decode(video_info["data"]["video_list"]["video_1"]["main_url"]).decode() except Exception: raise NotImplementedError(url) - filetype, ext, size = url_info(video_url) + filetype, ext, size = url_info(video_url, headers=headers or kwargs.get('headers', {})) print_info(site_info, title, filetype, size) if not info_only: - download_urls([video_url], title, ext, size, output_dir=output_dir) + _param = { + 'output_dir': output_dir, + 'headers': headers or kwargs.get('headers', {}) + } + download_urls([video_url], title, ext, size, **_param) + def ixigua_download_playlist(url, output_dir='.', info_only=False, **kwargs): """Download all video from the user's video list @@ -80,6 +95,7 @@ def ixigua_download_playlist(url, output_dir='.', info_only=False, **kwargs): for i in get_moment(**_param): ixigua_download(i, output_dir, info_only, **kwargs) + site_info = "ixigua.com" download = ixigua_download -download_playlist = ixigua_download_playlist \ No newline at end of file +download_playlist = ixigua_download_playlist From 7633898850f6ed30c78e1fb5bdb0f96b81d9d87a Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 1 Mar 2018 22:55:09 +0100 Subject: [PATCH 22/32] version 0.4.1040 --- src/you_get/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/version.py b/src/you_get/version.py index 2d4ff9d0..7e220d0d 100644 --- a/src/you_get/version.py +++ b/src/you_get/version.py @@ -1,4 +1,4 @@ #!/usr/bin/env python script_name = 'you-get' -__version__ = '0.4.1025' +__version__ = '0.4.1040' From 1900f7608cc2756d5460c99eb792c8e0eb42e7f4 Mon Sep 17 00:00:00 2001 From: mq-liu Date: Wed, 7 Mar 2018 09:48:11 +0800 Subject: [PATCH 23/32] fix bilibili download fail the bilibili api has changed "https://interface.bilibili.com/v2/playurl?cid=33250486&appkey=84956560bc028eb7&otype=json&type=&quality=0&qn=0&sign=a1b0401c8bf70d676bab133fa032469f" --- src/you_get/extractors/bilibili.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index e5abccab..046d2cb1 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -23,7 +23,7 @@ from .youku import youku_download_by_vid class Bilibili(VideoExtractor): name = 'Bilibili' live_api = 'http://live.bilibili.com/api/playurl?cid={}&otype=json' - api_url = 'http://interface.bilibili.com/playurl?' + api_url = 'http://interface.bilibili.com/v2/playurl?' bangumi_api_url = 'http://bangumi.bilibili.com/player/web_api/playurl?' live_room_init_api_url = 'https://api.live.bilibili.com/room/v1/Room/room_init?id={}' live_room_info_api_url = 'https://api.live.bilibili.com/room/v1/Room/get_info?room_id={}' From 92eb72bc7d20370e2835ed78dad94c0accaa068a Mon Sep 17 00:00:00 2001 From: Kugel-Blitz <21170940+Kugel-Blitz@users.noreply.github.com> Date: Sun, 11 Mar 2018 10:06:19 +1300 Subject: [PATCH 24/32] Use 0513 when cookies are used 0507 doesn't seem to honour cookies when they're loaded. --- src/you_get/extractors/youku.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index 9d74b9c8..d40d16c1 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -78,7 +78,10 @@ class Youku(VideoExtractor): self.api_error_code = None self.api_error_msg = None - self.ccode = '0513' + if cookies: + self.ccode = '0513' + else: + self.ccode = '0507' self.utid = None def youku_ups(self): From 344502af0d223def2a9ed0fde3766f6f7490b23b Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 15 Mar 2018 22:38:23 +0100 Subject: [PATCH 25/32] [youku] resolve conflict --- src/you_get/extractors/youku.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index 099552cf..d40d16c1 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -78,7 +78,10 @@ class Youku(VideoExtractor): self.api_error_code = None self.api_error_msg = None - self.ccode = '0507' + if cookies: + self.ccode = '0513' + else: + self.ccode = '0507' self.utid = None def youku_ups(self): From fdf53508388135917bb976319b2be01b96034634 Mon Sep 17 00:00:00 2001 From: Phun Date: Mon, 19 Mar 2018 12:48:38 +0800 Subject: [PATCH 26/32] fix the bug of v.qq.com --- src/you_get/extractors/qq.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/qq.py b/src/you_get/extractors/qq.py index 89dd7b61..5591e3eb 100644 --- a/src/you_get/extractors/qq.py +++ b/src/you_get/extractors/qq.py @@ -122,9 +122,9 @@ def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs): return #do redirect - if 'v.qq.com/page' in url: + if 'v.qq.com/x' in url: # for URLs like this: - # http://v.qq.com/page/k/9/7/k0194pwgw97.html + # https://v.qq.com/x/page/r05533mns3s.html new_url = url_locations([url])[0] if url == new_url: #redirect in js? From 3faaebb6762ff1bbea1e9b45b6dd348a92ddbcfc Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 22 Mar 2018 22:40:07 +0100 Subject: [PATCH 27/32] [qq] no more redirect (close #2586) --- src/you_get/extractors/qq.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/you_get/extractors/qq.py b/src/you_get/extractors/qq.py index 5591e3eb..ffca5a85 100644 --- a/src/you_get/extractors/qq.py +++ b/src/you_get/extractors/qq.py @@ -121,18 +121,6 @@ def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs): qq_download_by_vid(vid, vid, output_dir, merge, info_only) return - #do redirect - if 'v.qq.com/x' in url: - # for URLs like this: - # https://v.qq.com/x/page/r05533mns3s.html - new_url = url_locations([url])[0] - if url == new_url: - #redirect in js? - content = get_content(url) - url = match1(content,r'window\.location\.href="(.*?)"') - else: - url = new_url - if 'kuaibao.qq.com' in url or re.match(r'http://daxue.qq.com/content/content/id/\d+', url): content = get_content(url) vid = match1(content, r'vid\s*=\s*"\s*([^"]+)"') From 8979cd63eaa0979f249e4132a10b3706c4952b02 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 22 Mar 2018 22:44:33 +0100 Subject: [PATCH 28/32] [qq] break if no pay --- src/you_get/extractors/qq.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/you_get/extractors/qq.py b/src/you_get/extractors/qq.py index ffca5a85..7b1a6860 100644 --- a/src/you_get/extractors/qq.py +++ b/src/you_get/extractors/qq.py @@ -47,6 +47,9 @@ def qq_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False): else: log.w(key_json['msg']) break + if key_json.get('filename') is None: + log.w(key_json['msg']) + break part_urls.append(url) _, ext, size = url_info(url) From 821e639e025296b4c041d0535ca4d95ad72ea397 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Thu, 22 Mar 2018 22:46:12 +0100 Subject: [PATCH 29/32] [youku] boom boom boom --- src/you_get/extractors/youku.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index d40d16c1..bc4d8088 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -78,10 +78,7 @@ class Youku(VideoExtractor): self.api_error_code = None self.api_error_msg = None - if cookies: - self.ccode = '0513' - else: - self.ccode = '0507' + self.ccode = '0590' self.utid = None def youku_ups(self): From d3719ed4b62be2697e18755bcda7cb2249c8d7c1 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sat, 24 Mar 2018 23:56:38 +0100 Subject: [PATCH 30/32] [bilibili] warn when target URL is a playlist --- src/you_get/extractors/bilibili.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index 046d2cb1..7e5bdb37 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -167,8 +167,8 @@ class Bilibili(VideoExtractor): qq_download_by_vid(tc_flashvars, self.title, output_dir=kwargs['output_dir'], merge=kwargs['merge'], info_only=kwargs['info_only']) return - has_plist = re.search(r' Date: Mon, 26 Mar 2018 12:05:12 +0200 Subject: [PATCH 31/32] from ..common import general_m3u8_extractor Import the definition of __general_m3u8_extractor()__ for the function call on line 64... flake8 testing of https://github.com/soimort/you-get on Python 3.6.3 $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./src/you_get/extractors/longzhu.py:63:20: F821 undefined name 'general_m3u8_extractor' urls = general_m3u8_extractor(real_url) ^ 1 F821 undefined name 'general_m3u8_extractor' ``` --- src/you_get/extractors/longzhu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/longzhu.py b/src/you_get/extractors/longzhu.py index ed0cb084..29b340c5 100644 --- a/src/you_get/extractors/longzhu.py +++ b/src/you_get/extractors/longzhu.py @@ -5,6 +5,7 @@ __all__ = ['longzhu_download'] import json from ..common import ( get_content, + general_m3u8_extractor, match1, print_info, download_urls, @@ -70,4 +71,4 @@ def longzhu_download(url, output_dir = '.', merge=True, info_only=False, **kwarg site_info = 'longzhu.com' download = longzhu_download -download_playlist = playlist_not_supported('longzhu') \ No newline at end of file +download_playlist = playlist_not_supported('longzhu') From 43923bc8f6c7df552e672a4e80aed0e58010964d Mon Sep 17 00:00:00 2001 From: JayXon Date: Thu, 29 Mar 2018 00:59:28 -0700 Subject: [PATCH 32/32] [youku] use default ckey 1080p works --- src/you_get/extractors/youku.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/you_get/extractors/youku.py b/src/you_get/extractors/youku.py index bc4d8088..fc1a5cd2 100644 --- a/src/you_get/extractors/youku.py +++ b/src/you_get/extractors/youku.py @@ -78,7 +78,10 @@ class Youku(VideoExtractor): self.api_error_code = None self.api_error_msg = None - self.ccode = '0590' + self.ccode = '0502' + # Found in http://g.alicdn.com/player/ykplayer/0.5.28/youku-player.min.js + # grep -oE '"[0-9a-zA-Z+/=]{256}"' youku-player.min.js + self.ckey = 'DIl58SLFxFNndSV1GFNnMQVYkx1PP5tKe1siZu/86PR1u/Wh1Ptd+WOZsHHWxysSfAOhNJpdVWsdVJNsfJ8Sxd8WKVvNfAS8aS8fAOzYARzPyPc3JvtnPHjTdKfESTdnuTW6ZPvk2pNDh4uFzotgdMEFkzQ5wZVXl2Pf1/Y6hLK0OnCNxBj3+nb0v72gZ6b0td+WOZsHHWxysSo/0y9D2K42SaB8Y/+aD2K42SaB8Y/+ahU+WOZsHcrxysooUeND' self.utid = None def youku_ups(self): @@ -86,6 +89,7 @@ class Youku(VideoExtractor): url += '&client_ip=192.168.1.1' url += '&utid=' + self.utid url += '&client_ts=' + str(int(time.time())) + url += '&ckey=' + urllib.parse.quote(self.ckey) if self.password_protected: url += '&password=' + self.password headers = dict(Referer=self.referer)