]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/douyutv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..utils
import ExtractorError
8 class DouyuTVIE(InfoExtractor
):
9 _VALID_URL
= r
'http://(?:www\.)?douyutv\.com/(?P<id>[A-Za-z0-9]+)'
11 'url': 'http://www.douyutv.com/iseven',
15 'title': 're:^清晨醒脑!T-ara根本停不下来! [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
16 'description': 'md5:9e525642c25a0a24302869937cf69d17',
17 'thumbnail': 're:^https?://.*\.jpg$',
19 'uploader_id': '431925',
23 'skip_download': True,
27 def _real_extract(self
, url
):
28 video_id
= self
._match
_id
(url
)
30 config
= self
._download
_json
(
31 'http://www.douyutv.com/api/client/room/%s' % video_id
, video_id
)
35 error_code
= config
.get('error', 0)
36 show_status
= data
.get('show_status')
37 if error_code
is not 0:
39 'Server reported error %i' % error_code
, expected
=True)
41 # 1 = live, 2 = offline
42 if show_status
== '2':
44 'Live stream is offline', expected
=True)
46 base_url
= data
['rtmp_url']
47 live_path
= data
['rtmp_live']
49 title
= self
._live
_title
(data
['room_name'])
50 description
= data
.get('show_details')
51 thumbnail
= data
.get('room_src')
53 uploader
= data
.get('nickname')
54 uploader_id
= data
.get('owner_uid')
56 multi_formats
= data
.get('rtmp_multi_bitrate')
57 if not isinstance(multi_formats
, dict):
59 multi_formats
['live'] = live_path
62 'url': '%s/%s' % (base_url
, format_path
),
63 'format_id': format_id
,
64 'preference': 1 if format_id
== 'live' else 0,
65 } for format_id
, format_path
in multi_formats
.items()]
66 self
._sort
_formats
(formats
)
71 'description': description
,
72 'thumbnail': thumbnail
,
74 'uploader_id': uploader_id
,