This commit is contained in:
hcwhan 2020-10-08 22:09:40 +08:00 committed by GitHub
commit bf9c3bb82c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 16 deletions

View File

@ -82,29 +82,22 @@ class DouyuTVIE(InfoExtractor):
room_id = self._html_search_regex(
r'"room_id\\?"\s*:\s*(\d+),', page, 'room id')
# Grab metadata from mobile API
room = self._download_json(
'http://m.douyu.com/html5/live?roomId=%s' % room_id, video_id,
# Grab metadata from PC client API
api_url = 'http://www.douyutv.com/api/v1/'
args = 'room/%s?aid=wp&client_sys=wp&time=%d' % (room_id, int(time.time()))
auth_str = (args + 'zNzMV1y4EMxOHS6I5WKm').encode('utf-8')
auth_md5 = hashlib.md5(auth_str).hexdigest()
json_request_url = '%s%s&auth=%s' % (api_url, args, auth_md5)
room = self._download_json(json_request_url, video_id,
note='Downloading room info')['data']
# 1 = live, 2 = offline
if room.get('show_status') == '2':
raise ExtractorError('Live stream is offline', expected=True)
# Grab the URL from PC client API
# The m3u8 url from mobile API requires re-authentication every 5 minutes
tt = int(time.time())
signContent = 'lapi/live/thirdPart/getPlay/%s?aid=pcclient&rate=0&time=%d9TUk5fjjUjg9qIMH3sdnh' % (room_id, tt)
sign = hashlib.md5(signContent.encode('ascii')).hexdigest()
video_url = self._download_json(
'http://coapi.douyucdn.cn/lapi/live/thirdPart/getPlay/' + room_id,
video_id, note='Downloading video URL info',
query={'rate': 0}, headers={
'auth': sign,
'time': str(tt),
'aid': 'pcclient'
})['data']['live_url']
video_url = room.get('rtmp_url') + '/' + room.get('rtmp_live')
title = self._live_title(unescapeHTML(room['room_name']))
description = room.get('show_details')
thumbnail = room.get('room_src')