1 from .common
import InfoExtractor
2 from ..networking
.exceptions
import HTTPError
13 class FlexTVIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?flextv\.co\.kr/channels/(?P<id>\d+)/live'
16 'url': 'https://www.flextv.co.kr/channels/231638/live',
20 'title': r
're:^214하나만\.\.\. ',
21 'thumbnail': r
're:^https?://.+\.jpg',
22 'upload_date': r
're:\d{8}',
24 'live_status': 'is_live',
26 'channel_id': '244396',
28 'skip': 'The channel is offline',
30 'url': 'https://www.flextv.co.kr/channels/746/live',
31 'only_matching': True,
34 def _real_extract(self
, url
):
35 channel_id
= self
._match
_id
(url
)
38 stream_data
= self
._download
_json
(
39 f
'https://api.flextv.co.kr/api/channels/{channel_id}/stream',
40 channel_id
, query
={'option': 'all'})
41 except ExtractorError
as e
:
42 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 400:
43 raise UserNotLive(video_id
=channel_id
)
46 playlist_url
= stream_data
['sources'][0]['url']
47 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
48 playlist_url
, channel_id
, 'mp4')
53 'subtitles': subtitles
,
55 **traverse_obj(stream_data
, {
56 'title': ('stream', 'title', {str}
),
57 'timestamp': ('stream', 'createdAt', {parse_iso8601}
),
58 'thumbnail': ('thumbUrl', {url_or_none}
),
59 'channel': ('owner', 'name', {str}
),
60 'channel_id': ('owner', 'id', {str_or_none}
),