From 8eb703edbeb5629bc513a0c7f9201465a617145f Mon Sep 17 00:00:00 2001
From: GuanFoxyier <1372851437@qq.com>
Date: Thu, 23 May 2019 11:12:49 +0800
Subject: [PATCH 1/5] fix le
---
src/you_get/extractors/le.py | 86 +++++++++++++++++++-----------------
1 file changed, 46 insertions(+), 40 deletions(-)
diff --git a/src/you_get/extractors/le.py b/src/you_get/extractors/le.py
index 940b9b35..af49c2dc 100644
--- a/src/you_get/extractors/le.py
+++ b/src/you_get/extractors/le.py
@@ -9,13 +9,16 @@ import base64, hashlib, urllib, time, re
from ..common import *
-#@DEPRECATED
+
+# @DEPRECATED
def get_timestamp():
tn = random.random()
url = 'http://api.letv.com/time?tn={}'.format(tn)
result = get_content(url)
return json.loads(result)['stime']
-#@DEPRECATED
+
+
+# @DEPRECATED
def get_key(t):
for s in range(0, 8):
e = 1 & t
@@ -24,42 +27,40 @@ def get_key(t):
t += e
return t ^ 185025305
+
def calcTimeKey(t):
- ror = lambda val, r_bits, : ((val & (2**32-1)) >> r_bits%32) | (val << (32-(r_bits%32)) & (2**32-1))
+ ror = lambda val, r_bits,: ((val & (2 ** 32 - 1)) >> r_bits % 32) | (val << (32 - (r_bits % 32)) & (2 ** 32 - 1))
magic = 185025305
return ror(t, magic % 17) ^ magic
- #return ror(ror(t,773625421%13)^773625421,773625421%17)
+ # return ror(ror(t,773625421%13)^773625421,773625421%17)
def decode(data):
version = data[0:5]
if version.lower() == b'vc_01':
- #get real m3u8
+ # get real m3u8
loc2 = data[5:]
length = len(loc2)
- loc4 = [0]*(2*length)
+ loc4 = [0] * (2 * length)
for i in range(length):
- loc4[2*i] = loc2[i] >> 4
- loc4[2*i+1]= loc2[i] & 15;
- loc6 = loc4[len(loc4)-11:]+loc4[:len(loc4)-11]
- loc7 = [0]*length
+ loc4[2 * i] = loc2[i] >> 4
+ loc4[2 * i + 1] = loc2[i] & 15;
+ loc6 = loc4[len(loc4) - 11:] + loc4[:len(loc4) - 11]
+ loc7 = [0] * length
for i in range(length):
- loc7[i] = (loc6[2 * i] << 4) +loc6[2*i+1]
+ loc7[i] = (loc6[2 * i] << 4) + loc6[2 * i + 1]
return ''.join([chr(i) for i in loc7])
else:
# directly return
- return data
+ return str(data)
-
-
-def video_info(vid,**kwargs):
- url = 'http://player-pc.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com®ion=cn&source=1000&accesyx=1'.format(vid,calcTimeKey(int(time.time())))
+def video_info(vid, **kwargs):
+ url = 'http://player-pc.le.com/mms/out/video/playJson?id={}&platid=1&splatid=105&format=1&tkey={}&domain=www.le.com®ion=cn&source=1000&accesyx=1'.format(vid, calcTimeKey(int(time.time())))
r = get_content(url, decoded=False)
- info=json.loads(str(r,"utf-8"))
+ info = json.loads(str(r, "utf-8"))
info = info['msgs']
-
stream_id = None
support_stream_id = info["playurl"]["dispatch"].keys()
if "stream_id" in kwargs and kwargs["stream_id"].lower() in support_stream_id:
@@ -70,27 +71,28 @@ def video_info(vid,**kwargs):
elif "720p" in support_stream_id:
stream_id = '720p'
else:
- stream_id =sorted(support_stream_id,key= lambda i: int(i[1:]))[-1]
+ stream_id = sorted(support_stream_id, key=lambda i: int(i[1:]))[-1]
- url =info["playurl"]["domain"][0]+info["playurl"]["dispatch"][stream_id][0]
+ url = info["playurl"]["domain"][0] + info["playurl"]["dispatch"][stream_id][0]
uuid = hashlib.sha1(url.encode('utf8')).hexdigest() + '_0'
ext = info["playurl"]["dispatch"][stream_id][1].split('.')[-1]
url = url.replace('tss=0', 'tss=ios')
- url+="&m3v=1&termid=1&format=1&hwtype=un&ostype=MacOS10.12.4&p1=1&p2=10&p3=-&expect=3&tn={}&vid={}&uuid={}&sign=letv".format(random.random(), vid, uuid)
+ url += "&m3v=1&termid=1&format=1&hwtype=un&ostype=MacOS10.12.4&p1=1&p2=10&p3=-&expect=3&tn={}&vid={}&uuid={}&sign=letv".format(random.random(), vid, uuid)
- r2=get_content(url,decoded=False)
- info2=json.loads(str(r2,"utf-8"))
+ r2 = get_content(url, decoded=False)
+ info2 = json.loads(str(r2, "utf-8"))
# hold on ! more things to do
# to decode m3u8 (encoded)
suffix = '&r=' + str(int(time.time() * 1000)) + '&appid=500'
- m3u8 = get_content(info2["location"]+suffix,decoded=False)
+ m3u8 = get_content(info2["location"] + suffix, decoded=False)
m3u8_list = decode(m3u8)
- urls = re.findall(r'^[^#][^\r]*',m3u8_list,re.MULTILINE)
- return ext,urls
+ urls = re.findall(r'(http.*?)#', m3u8_list, re.MULTILINE)
+ return ext, urls
-def letv_download_by_vid(vid,title, output_dir='.', merge=True, info_only=False,**kwargs):
- ext , urls = video_info(vid,**kwargs)
+
+def letv_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False, **kwargs):
+ ext, urls = video_info(vid, **kwargs)
size = 0
for i in urls:
_, _, tmp = url_info(i)
@@ -100,27 +102,29 @@ def letv_download_by_vid(vid,title, output_dir='.', merge=True, info_only=False,
if not info_only:
download_urls(urls, title, ext, size, output_dir=output_dir, merge=merge)
+
def letvcloud_download_by_vu(vu, uu, title=None, output_dir='.', merge=True, info_only=False):
- #ran = float('0.' + str(random.randint(0, 9999999999999999))) # For ver 2.1
- #str2Hash = 'cfflashformatjsonran{ran}uu{uu}ver2.2vu{vu}bie^#@(%27eib58'.format(vu = vu, uu = uu, ran = ran) #Magic!/ In ver 2.1
- argumet_dict ={'cf' : 'flash', 'format': 'json', 'ran': str(int(time.time())), 'uu': str(uu),'ver': '2.2', 'vu': str(vu), }
- sign_key = '2f9d6924b33a165a6d8b5d3d42f4f987' #ALL YOUR BASE ARE BELONG TO US
+ # ran = float('0.' + str(random.randint(0, 9999999999999999))) # For ver 2.1
+ # str2Hash = 'cfflashformatjsonran{ran}uu{uu}ver2.2vu{vu}bie^#@(%27eib58'.format(vu = vu, uu = uu, ran = ran) #Magic!/ In ver 2.1
+ argumet_dict = {'cf': 'flash', 'format': 'json', 'ran': str(int(time.time())), 'uu': str(uu), 'ver': '2.2', 'vu': str(vu), }
+ sign_key = '2f9d6924b33a165a6d8b5d3d42f4f987' # ALL YOUR BASE ARE BELONG TO US
str2Hash = ''.join([i + argumet_dict[i] for i in sorted(argumet_dict)]) + sign_key
sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
- request_info = urllib.request.Request('http://api.letvcloud.com/gpc.php?' + '&'.join([i + '=' + argumet_dict[i] for i in argumet_dict]) + '&sign={sign}'.format(sign = sign))
+ request_info = urllib.request.Request('http://api.letvcloud.com/gpc.php?' + '&'.join([i + '=' + argumet_dict[i] for i in argumet_dict]) + '&sign={sign}'.format(sign=sign))
response = urllib.request.urlopen(request_info)
data = response.read()
info = json.loads(data.decode('utf-8'))
type_available = []
for video_type in info['data']['video_info']['media']:
type_available.append({'video_url': info['data']['video_info']['media'][video_type]['play_url']['main_url'], 'video_quality': int(info['data']['video_info']['media'][video_type]['play_url']['vtype'])})
- urls = [base64.b64decode(sorted(type_available, key = lambda x:x['video_quality'])[-1]['video_url']).decode("utf-8")]
+ urls = [base64.b64decode(sorted(type_available, key=lambda x: x['video_quality'])[-1]['video_url']).decode("utf-8")]
size = urls_size(urls)
ext = 'mp4'
print_info(site_info, title, ext, size)
if not info_only:
download_urls(urls, title, ext, size, output_dir=output_dir, merge=merge)
+
def letvcloud_download(url, output_dir='.', merge=True, info_only=False):
qs = parse.urlparse(url).query
vu = match1(qs, r'vu=([\w]+)')
@@ -128,7 +132,8 @@ def letvcloud_download(url, output_dir='.', merge=True, info_only=False):
title = "LETV-%s" % vu
letvcloud_download_by_vu(vu, uu, title=title, output_dir=output_dir, merge=merge, info_only=info_only)
-def letv_download(url, output_dir='.', merge=True, info_only=False ,**kwargs):
+
+def letv_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
url = url_locations([url])[0]
if re.match(r'http://yuntv.letv.com/', url):
letvcloud_download(url, output_dir=output_dir, merge=merge, info_only=info_only)
@@ -136,14 +141,15 @@ def letv_download(url, output_dir='.', merge=True, info_only=False ,**kwargs):
html = get_content(url)
vid = match1(url, r'video/(\d+)\.html')
title = match1(html, r'
([^<]+)
')
- letv_download_by_vid(vid, title=title, output_dir=output_dir, merge=merge, info_only=info_only,**kwargs)
+ letv_download_by_vid(vid, title=title, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
else:
html = get_content(url)
vid = match1(url, r'http://www.letv.com/ptv/vplay/(\d+).html') or \
- match1(url, r'http://www.le.com/ptv/vplay/(\d+).html') or \
- match1(html, r'vid="(\d+)"')
- title = match1(html,r'name="irTitle" content="(.*?)"')
- letv_download_by_vid(vid, title=title, output_dir=output_dir, merge=merge, info_only=info_only,**kwargs)
+ match1(url, r'http://www.le.com/ptv/vplay/(\d+).html') or \
+ match1(html, r'vid="(\d+)"')
+ title = match1(html, r'name="irTitle" content="(.*?)"')
+ letv_download_by_vid(vid, title=title, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
+
site_info = "Le.com"
download = letv_download
From 5e5d2540d5bcff8f1e88427b7147ce3d255e5818 Mon Sep 17 00:00:00 2001
From: GuanFoxyier <1372851437@qq.com>
Date: Fri, 24 May 2019 14:33:17 +0800
Subject: [PATCH 2/5] fix sohu
---
src/you_get/extractors/sohu.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/you_get/extractors/sohu.py b/src/you_get/extractors/sohu.py
index 607bf44c..63971bc3 100644
--- a/src/you_get/extractors/sohu.py
+++ b/src/you_get/extractors/sohu.py
@@ -15,11 +15,13 @@ Changelog:
new api
'''
+
def real_url(fileName, key, ch):
url = "https://data.vod.itc.cn/ip?new=" + fileName + "&num=1&key=" + key + "&ch=" + ch + "&pt=1&pg=2&prod=h5n"
return json.loads(get_html(url))['servers'][0]['url']
-def sohu_download(url, output_dir = '.', merge = True, info_only = False, extractor_proxy=None, **kwargs):
+
+def sohu_download(url, output_dir='.', merge=True, info_only=False, extractor_proxy=None, **kwargs):
if re.match(r'http://share.vrs.sohu.com', url):
vid = r1('id=(\d+)', url)
else:
@@ -31,12 +33,12 @@ def sohu_download(url, output_dir = '.', merge = True, info_only = False, extrac
if extractor_proxy:
set_proxy(tuple(extractor_proxy.split(":")))
info = json.loads(get_decoded_html('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid))
- for qtyp in ["oriVid","superVid","highVid" ,"norVid","relativeId"]:
+ for qtyp in ["oriVid", "superVid", "highVid", "norVid", "relativeId"]:
if 'data' in info:
hqvid = info['data'][qtyp]
else:
hqvid = info[qtyp]
- if hqvid != 0 and hqvid != vid :
+ if hqvid != 0 and hqvid != vid:
info = json.loads(get_decoded_html('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % hqvid))
if not 'allot' in info:
continue
@@ -63,14 +65,15 @@ def sohu_download(url, output_dir = '.', merge = True, info_only = False, extrac
urls = []
data = info['data']
title = data['tvName']
- size = sum(map(int,data['clipsBytes']))
+ size = sum(map(int, data['clipsBytes']))
assert len(data['clipsURL']) == len(data['clipsBytes']) == len(data['su'])
for fileName, key in zip(data['su'], data['ck']):
urls.append(real_url(fileName, key, data['ch']))
print_info(site_info, title, 'mp4', size)
if not info_only:
- download_urls(urls, title, 'mp4', size, output_dir, refer = url, merge = merge)
+ download_urls(urls, title, 'mp4', size, output_dir, refer=url, merge=merge)
+
site_info = "Sohu.com"
download = sohu_download
From 8c41765d1364fe77900cdbcb8e9ebf99757b625f Mon Sep 17 00:00:00 2001
From: GuanFoxyier <1372851437@qq.com>
Date: Fri, 24 May 2019 14:35:49 +0800
Subject: [PATCH 3/5] fix sohu
---
src/you_get/extractors/sohu.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/you_get/extractors/sohu.py b/src/you_get/extractors/sohu.py
index 63971bc3..a1afc126 100644
--- a/src/you_get/extractors/sohu.py
+++ b/src/you_get/extractors/sohu.py
@@ -29,10 +29,10 @@ def sohu_download(url, output_dir='.', merge=True, info_only=False, extractor_pr
vid = r1(r'\Wvid\s*[\:=]\s*[\'"]?(\d+)[\'"]?', html)
assert vid
- if re.match(r'http[s]://tv.sohu.com/', url):
- if extractor_proxy:
- set_proxy(tuple(extractor_proxy.split(":")))
- info = json.loads(get_decoded_html('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid))
+ if extractor_proxy:
+ set_proxy(tuple(extractor_proxy.split(":")))
+ info = json.loads(get_decoded_html('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid))
+ if info and info.get("data", ""):
for qtyp in ["oriVid", "superVid", "highVid", "norVid", "relativeId"]:
if 'data' in info:
hqvid = info['data'][qtyp]
From 1758cd0ae99b15047cef9f4ca4ba0bce18866ccd Mon Sep 17 00:00:00 2001
From: Mort Yao
Date: Tue, 11 Jun 2019 15:56:46 +0200
Subject: [PATCH 4/5] [youtube] signature -> sig (fix #2711)
---
src/you_get/extractors/youtube.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py
index 0629035b..eea31503 100644
--- a/src/you_get/extractors/youtube.py
+++ b/src/you_get/extractors/youtube.py
@@ -216,6 +216,7 @@ class YouTube(VideoExtractor):
self.html5player = 'https://www.youtube.com' + ytplayer_config['assets']['js']
# Workaround: get_video_info returns bad s. Why?
stream_list = ytplayer_config['args']['url_encoded_fmt_stream_map'].split(',')
+ #stream_list = ytplayer_config['args']['adaptive_fmts'].split(',')
except:
stream_list = video_info['url_encoded_fmt_stream_map'][0].split(',')
if re.search('([^"]*/base\.js)"', video_page):
@@ -306,7 +307,8 @@ class YouTube(VideoExtractor):
'url': metadata['url'][0],
'sig': metadata['sig'][0] if 'sig' in metadata else None,
's': metadata['s'][0] if 's' in metadata else None,
- 'quality': metadata['quality'][0],
+ 'quality': metadata['quality'][0] if 'quality' in metadata else None,
+ #'quality': metadata['quality_label'][0] if 'quality_label' in metadata else None,
'type': metadata['type'][0],
'mime': metadata['type'][0].split(';')[0],
'container': mime_to_container(metadata['type'][0].split(';')[0]),
@@ -433,13 +435,13 @@ class YouTube(VideoExtractor):
dash_mp4_a_url = stream['url']
if 's' in stream:
sig = self.__class__.decipher(self.js, stream['s'])
- dash_mp4_a_url += '&signature={}'.format(sig)
+ dash_mp4_a_url += '&sig={}'.format(sig)
dash_mp4_a_size = stream['clen']
elif stream['type'].startswith('audio/webm'):
dash_webm_a_url = stream['url']
if 's' in stream:
sig = self.__class__.decipher(self.js, stream['s'])
- dash_webm_a_url += '&signature={}'.format(sig)
+ dash_webm_a_url += '&sig={}'.format(sig)
dash_webm_a_size = stream['clen']
for stream in streams: # video
if 'size' in stream:
@@ -448,7 +450,7 @@ class YouTube(VideoExtractor):
dash_url = stream['url']
if 's' in stream:
sig = self.__class__.decipher(self.js, stream['s'])
- dash_url += '&signature={}'.format(sig)
+ dash_url += '&sig={}'.format(sig)
dash_size = stream['clen']
itag = stream['itag']
dash_urls = self.__class__.chunk_by_range(dash_url, int(dash_size))
@@ -467,7 +469,7 @@ class YouTube(VideoExtractor):
dash_url = stream['url']
if 's' in stream:
sig = self.__class__.decipher(self.js, stream['s'])
- dash_url += '&signature={}'.format(sig)
+ dash_url += '&sig={}'.format(sig)
dash_size = stream['clen']
itag = stream['itag']
audio_url = None
@@ -510,13 +512,13 @@ class YouTube(VideoExtractor):
src = self.streams[stream_id]['url']
if self.streams[stream_id]['sig'] is not None:
sig = self.streams[stream_id]['sig']
- src += '&signature={}'.format(sig)
+ src += '&sig={}'.format(sig)
elif self.streams[stream_id]['s'] is not None:
if not hasattr(self, 'js'):
self.js = get_content(self.html5player)
s = self.streams[stream_id]['s']
sig = self.__class__.decipher(self.js, s)
- src += '&signature={}'.format(sig)
+ src += '&sig={}'.format(sig)
self.streams[stream_id]['src'] = [src]
self.streams[stream_id]['size'] = urls_size(self.streams[stream_id]['src'])
From 2496decf24a8c8228137fdaf2391bcc6f74a9207 Mon Sep 17 00:00:00 2001
From: Mort Yao
Date: Tue, 11 Jun 2019 16:02:36 +0200
Subject: [PATCH 5/5] version 0.4.1314
---
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 654732ce..a31efa48 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.1302'
+__version__ = '0.4.1314'