|
|
@ -3,15 +3,19 @@ from ..networking.exceptions import HTTPError
|
|
|
|
from ..utils import (
|
|
|
|
from ..utils import (
|
|
|
|
ExtractorError,
|
|
|
|
ExtractorError,
|
|
|
|
UserNotLive,
|
|
|
|
UserNotLive,
|
|
|
|
|
|
|
|
int_or_none,
|
|
|
|
|
|
|
|
join_nonempty,
|
|
|
|
parse_iso8601,
|
|
|
|
parse_iso8601,
|
|
|
|
str_or_none,
|
|
|
|
str_or_none,
|
|
|
|
traverse_obj,
|
|
|
|
|
|
|
|
url_or_none,
|
|
|
|
url_or_none,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
from ..utils.traversal import traverse_obj
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FlexTVIE(InfoExtractor):
|
|
|
|
class FlexTVIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?flextv\.co\.kr/channels/(?P<id>\d+)/live'
|
|
|
|
IE_NAME = 'ttinglive'
|
|
|
|
|
|
|
|
IE_DESC = '띵라이브 (formerly FlexTV)'
|
|
|
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?(?:ttinglive\.com|flextv\.co\.kr)/channels/(?P<id>\d+)/live'
|
|
|
|
_TESTS = [{
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.flextv.co.kr/channels/231638/live',
|
|
|
|
'url': 'https://www.flextv.co.kr/channels/231638/live',
|
|
|
|
'info_dict': {
|
|
|
|
'info_dict': {
|
|
|
@ -36,21 +40,32 @@ class FlexTVIE(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
stream_data = self._download_json(
|
|
|
|
stream_data = self._download_json(
|
|
|
|
f'https://api.flextv.co.kr/api/channels/{channel_id}/stream',
|
|
|
|
f'https://api.ttinglive.com/api/channels/{channel_id}/stream',
|
|
|
|
channel_id, query={'option': 'all'})
|
|
|
|
channel_id, query={'option': 'all'})
|
|
|
|
except ExtractorError as e:
|
|
|
|
except ExtractorError as e:
|
|
|
|
if isinstance(e.cause, HTTPError) and e.cause.status == 400:
|
|
|
|
if isinstance(e.cause, HTTPError) and e.cause.status == 400:
|
|
|
|
raise UserNotLive(video_id=channel_id)
|
|
|
|
raise UserNotLive(video_id=channel_id)
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
playlist_url = stream_data['sources'][0]['url']
|
|
|
|
formats = []
|
|
|
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
|
|
|
for stream in traverse_obj(stream_data, ('sources', ..., {dict})):
|
|
|
|
playlist_url, channel_id, 'mp4')
|
|
|
|
if stream.get('format') == 'ivs' and url_or_none(stream.get('url')):
|
|
|
|
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
|
|
|
|
stream['url'], channel_id, 'mp4', live=True, fatal=False, m3u8_id='ivs'))
|
|
|
|
|
|
|
|
for format_type in ['hls', 'flv']:
|
|
|
|
|
|
|
|
for data in traverse_obj(stream, (
|
|
|
|
|
|
|
|
'urlDetail', format_type, 'resolution', lambda _, v: url_or_none(v['url']))):
|
|
|
|
|
|
|
|
formats.append({
|
|
|
|
|
|
|
|
'format_id': join_nonempty(format_type, data.get('suffixName'), delim=''),
|
|
|
|
|
|
|
|
'url': data['url'],
|
|
|
|
|
|
|
|
'height': int_or_none(data.get('resolution')),
|
|
|
|
|
|
|
|
'ext': 'mp4' if format_type == 'hls' else 'flv',
|
|
|
|
|
|
|
|
'protocol': 'm3u8_native' if format_type == 'hls' else 'http',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
'id': channel_id,
|
|
|
|
'id': channel_id,
|
|
|
|
'formats': formats,
|
|
|
|
'formats': formats,
|
|
|
|
'subtitles': subtitles,
|
|
|
|
|
|
|
|
'is_live': True,
|
|
|
|
'is_live': True,
|
|
|
|
**traverse_obj(stream_data, {
|
|
|
|
**traverse_obj(stream_data, {
|
|
|
|
'title': ('stream', 'title', {str}),
|
|
|
|
'title': ('stream', 'title', {str}),
|
|
|
|