mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
fix CI failure by using 3rd packages
This commit is contained in:
parent
6689f45469
commit
06b57e2db7
@ -8,13 +8,13 @@ import hashlib
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
import requests
|
||||
import urllib.parse, urllib.request
|
||||
|
||||
def douyutv_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
|
||||
room_id = url[url.rfind('/')+1:]
|
||||
|
||||
json_request_url = "http://m.douyu.com/html5/live?roomId=%s" % room_id
|
||||
content = get_html(json_request_url)
|
||||
content = get_content(json_request_url)
|
||||
data = json.loads(content)['data']
|
||||
server_status = data.get('error',0)
|
||||
if server_status is not 0:
|
||||
@ -27,14 +27,19 @@ def douyutv_download(url, output_dir = '.', merge = True, info_only = False, **k
|
||||
|
||||
tt = int(time.time() / 60)
|
||||
did = ''.join([random.choice(string.ascii_uppercase + string.digits) for n in range(32)])
|
||||
sign = hashlib.md5((room_id + did + 'A12Svb&%1UUmf@hC' + "%d" % tt).encode("utf-8")).hexdigest()
|
||||
sign_content = '{room_id}{did}A12Svb&%1UUmf@hC{tt}'.format(room_id = room_id, did = did, tt = tt)
|
||||
sign = hashlib.md5(sign_content.encode('utf-8')).hexdigest()
|
||||
|
||||
json_request_url = "http://www.douyu.com/lapi/live/getPlay/%s" % room_id
|
||||
|
||||
payload = {'cdn': 'ws', 'rate': '0', 'tt': tt, 'did': did, 'sign': sign}
|
||||
r = requests.post(json_request_url, data=payload)
|
||||
content = r.json()
|
||||
data = content['data']
|
||||
json_data = json.dumps(payload).encode('utf8')
|
||||
postdata = urllib.parse.urlencode(payload)
|
||||
req = urllib.request.Request(json_request_url, postdata.encode('utf-8'))
|
||||
with urllib.request.urlopen(req) as response:
|
||||
the_page = response.read()
|
||||
|
||||
content = json.loads(the_page.decode('utf-8'))
|
||||
data = content['data']
|
||||
server_status = data.get('error',0)
|
||||
if server_status is not 0:
|
||||
raise ValueError("Server returned error:%s" % server_status)
|
||||
@ -43,6 +48,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:
|
||||
print(real_url)
|
||||
download_url_ffmpeg(real_url, title, 'flv', None, output_dir, merge = merge)
|
||||
|
||||
site_info = "douyu.com"
|
||||
|
Loading…
Reference in New Issue
Block a user