]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/douyutv.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
14 class DouyuTVIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?douyu(?:tv)?\.com/(?:[^/]+/)*(?P<id>[A-Za-z0-9]+)'
18 'url': 'http://www.douyutv.com/iseven',
21 'display_id': 'iseven',
23 'title': 're:^清晨醒脑!T-ARA根本停不下来! [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
24 'description': r
're:.*m7show@163\.com.*',
25 'thumbnail': r
're:^https?://.*\.jpg$',
30 'skip_download': True,
33 'url': 'http://www.douyutv.com/85982',
36 'display_id': '85982',
38 'title': 're:^小漠从零单排记!——CSOL2躲猫猫 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
39 'description': 'md5:746a2f7a253966a06755a912f0acc0d2',
40 'thumbnail': r
're:^https?://.*\.jpg$',
41 'uploader': 'douyu小漠',
45 'skip_download': True,
47 'skip': 'Room not found',
49 'url': 'http://www.douyutv.com/17732',
52 'display_id': '17732',
54 'title': 're:^清晨醒脑!T-ARA根本停不下来! [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
55 'description': r
're:.*m7show@163\.com.*',
56 'thumbnail': r
're:^https?://.*\.jpg$',
61 'skip_download': True,
64 'url': 'http://www.douyu.com/xiaocang',
65 'only_matching': True,
68 'url': 'http://www.douyu.com/t/lpl',
69 'only_matching': True,
72 def _real_extract(self
, url
):
73 video_id
= self
._match
_id
(url
)
75 if video_id
.isdigit():
78 page
= self
._download
_webpage
(url
, video_id
)
79 room_id
= self
._html
_search
_regex
(
80 r
'"room_id\\?"\s*:\s*(\d+),', page
, 'room id')
82 # Grab metadata from mobile API
83 room
= self
._download
_json
(
84 'http://m.douyu.com/html5/live?roomId=%s' % room_id
, video_id
,
85 note
='Downloading room info')['data']
87 # 1 = live, 2 = offline
88 if room
.get('show_status') == '2':
89 raise ExtractorError('Live stream is offline', expected
=True)
91 # Grab the URL from PC client API
92 # The m3u8 url from mobile API requires re-authentication every 5 minutes
94 signContent
= 'lapi/live/thirdPart/getPlay/%s?aid=pcclient&rate=0&time=%d9TUk5fjjUjg9qIMH3sdnh' % (room_id
, tt
)
95 sign
= hashlib
.md5(signContent
.encode('ascii')).hexdigest()
96 video_url
= self
._download
_json
(
97 'http://coapi.douyucdn.cn/lapi/live/thirdPart/getPlay/' + room_id
,
98 video_id
, note
='Downloading video URL info',
99 query
={'rate': 0}, headers
={
103 })['data']['live_url']
105 title
= self
._live
_title
(unescapeHTML(room
['room_name']))
106 description
= room
.get('show_details')
107 thumbnail
= room
.get('room_src')
108 uploader
= room
.get('nickname')
112 'display_id': video_id
,
115 'description': description
,
116 'thumbnail': thumbnail
,
117 'uploader': uploader
,