]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/showroomlive.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_str
10 class ShowRoomLiveIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?showroom-live\.com/(?!onlive|timetable|event|campaign|news|ranking|room)(?P<id>[^/?#&]+)'
13 'url': 'https://www.showroom-live.com/48_Nana_Okada',
14 'only_matching': True,
17 def _real_extract(self
, url
):
18 broadcaster_id
= self
._match
_id
(url
)
20 webpage
= self
._download
_webpage
(url
, broadcaster_id
)
22 room_id
= self
._search
_regex
(
23 (r
'SrGlobal\.roomId\s*=\s*(\d+)',
24 r
'(?:profile|room)\?room_id\=(\d+)'), webpage
, 'room_id')
26 room
= self
._download
_json
(
27 urljoin(url
, '/api/room/profile?room_id=%s' % room_id
),
30 is_live
= room
.get('is_onlive')
31 if is_live
is not True:
32 raise ExtractorError('%s is offline' % broadcaster_id
, expected
=True)
34 uploader
= room
.get('performer_name') or broadcaster_id
35 title
= room
.get('room_name') or room
.get('main_name') or uploader
37 streaming_url_list
= self
._download
_json
(
38 urljoin(url
, '/api/live/streaming_url?room_id=%s' % room_id
),
39 broadcaster_id
)['streaming_url_list']
42 for stream
in streaming_url_list
:
43 stream_url
= stream
.get('url')
46 stream_type
= stream
.get('type')
47 if stream_type
== 'hls':
48 m3u8_formats
= self
._extract
_m
3u8_formats
(
49 stream_url
, broadcaster_id
, ext
='mp4', m3u8_id
='hls',
51 for f
in m3u8_formats
:
52 f
['quality'] = int_or_none(stream
.get('quality', 100))
53 formats
.extend(m3u8_formats
)
54 elif stream_type
== 'rtmp':
55 stream_name
= stream
.get('stream_name')
60 'play_path': stream_name
,
62 'player_url': 'https://www.showroom-live.com/assets/swf/v3/ShowRoomLive.swf',
66 'format_note': stream
.get('label'),
67 'quality': int_or_none(stream
.get('quality', 100)),
71 'id': compat_str(room
.get('live_id') or broadcaster_id
),
73 'description': room
.get('description'),
74 'timestamp': int_or_none(room
.get('current_live_started_at')),
76 'uploader_id': broadcaster_id
,
77 'view_count': int_or_none(room
.get('view_num')),