2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class DouyuTVIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?douyu(?:tv)?\.com/(?:[^/]+/)*(?P<id>[A-Za-z0-9]+)'
15 'url': 'http://www.douyutv.com/iseven',
18 'display_id': 'iseven',
20 'title': 're:^清晨醒脑!T-ARA根本停不下来! [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
21 'description': r're:.*m7show@163\.com.*',
22 'thumbnail': r're:^https?://.*\.jpg$',
27 'skip_download': True,
30 'url': 'http://www.douyutv.com/85982',
33 'display_id': '85982',
35 'title': 're:^小漠从零单排记!——CSOL2躲猫猫 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
36 'description': 'md5:746a2f7a253966a06755a912f0acc0d2',
37 'thumbnail': r're:^https?://.*\.jpg$',
38 'uploader': 'douyu小漠',
42 'skip_download': True,
44 'skip': 'Room not found',
46 'url': 'http://www.douyutv.com/17732',
49 'display_id': '17732',
51 'title': 're:^清晨醒脑!T-ARA根本停不下来! [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
52 'description': r're:.*m7show@163\.com.*',
53 'thumbnail': r're:^https?://.*\.jpg$',
58 'skip_download': True,
61 'url': 'http://www.douyu.com/xiaocang',
62 'only_matching': True,
65 'url': 'http://www.douyu.com/t/lpl',
66 'only_matching': True,
69 # Decompile core.swf in webpage by ffdec "Search SWFs in memory". core.swf
70 # is encrypted originally, but ffdec can dump memory to get the decrypted one.
71 _API_KEY = 'A12Svb&%1UUmf@hC'
73 def _real_extract(self, url):
74 video_id = self._match_id(url)
76 if video_id.isdigit():
79 page = self._download_webpage(url, video_id)
80 room_id = self._html_search_regex(
81 r'"room_id\\?"\s*:\s*(\d+),', page, 'room id')
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 formats = self._extract_m3u8_formats(
92 room['hls_url'], video_id, ext='mp4')
94 title = self._live_title(unescapeHTML(room['room_name']))
95 description = room.get('show_details')
96 thumbnail = room.get('room_src')
97 uploader = room.get('nickname')
101 'display_id': video_id,
104 'description': description,
105 'thumbnail': thumbnail,
106 'uploader': uploader,