|
|
@ -5,12 +5,14 @@ import itertools
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .common import InfoExtractor
|
|
|
|
|
|
|
|
from ..downloader.websocket import has_websockets
|
|
|
|
from ..utils import (
|
|
|
|
from ..utils import (
|
|
|
|
clean_html,
|
|
|
|
clean_html,
|
|
|
|
float_or_none,
|
|
|
|
float_or_none,
|
|
|
|
get_element_by_class,
|
|
|
|
get_element_by_class,
|
|
|
|
get_element_by_id,
|
|
|
|
get_element_by_id,
|
|
|
|
parse_duration,
|
|
|
|
parse_duration,
|
|
|
|
|
|
|
|
qualities,
|
|
|
|
str_to_int,
|
|
|
|
str_to_int,
|
|
|
|
try_get,
|
|
|
|
try_get,
|
|
|
|
unified_timestamp,
|
|
|
|
unified_timestamp,
|
|
|
@ -89,9 +91,24 @@ class TwitCastingIE(InfoExtractor):
|
|
|
|
video_js_data = video_js_data[0]
|
|
|
|
video_js_data = video_js_data[0]
|
|
|
|
m3u8_url = try_get(video_js_data, lambda x: x['source']['url'])
|
|
|
|
m3u8_url = try_get(video_js_data, lambda x: x['source']['url'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stream_server_data = self._download_json(
|
|
|
|
|
|
|
|
'https://twitcasting.tv/streamserver.php?target=%s&mode=client' % uploader_id, video_id,
|
|
|
|
|
|
|
|
'Downloading live info', fatal=False)
|
|
|
|
|
|
|
|
|
|
|
|
is_live = 'data-status="online"' in webpage
|
|
|
|
is_live = 'data-status="online"' in webpage
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
if is_live and not m3u8_url:
|
|
|
|
if is_live and not m3u8_url:
|
|
|
|
m3u8_url = 'https://twitcasting.tv/%s/metastream.m3u8' % uploader_id
|
|
|
|
m3u8_url = 'https://twitcasting.tv/%s/metastream.m3u8' % uploader_id
|
|
|
|
|
|
|
|
if is_live and has_websockets and stream_server_data:
|
|
|
|
|
|
|
|
qq = qualities(['base', 'mobilesource', 'main'])
|
|
|
|
|
|
|
|
for mode, ws_url in stream_server_data['llfmp4']['streams'].items():
|
|
|
|
|
|
|
|
formats.append({
|
|
|
|
|
|
|
|
'url': ws_url,
|
|
|
|
|
|
|
|
'format_id': 'ws-%s' % mode,
|
|
|
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
|
|
|
'quality': qq(mode),
|
|
|
|
|
|
|
|
'protocol': 'websocket_frag', # TwitCasting simply sends moof atom directly over WS
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
thumbnail = video_js_data.get('thumbnailUrl') or self._og_search_thumbnail(webpage)
|
|
|
|
thumbnail = video_js_data.get('thumbnailUrl') or self._og_search_thumbnail(webpage)
|
|
|
|
description = clean_html(get_element_by_id(
|
|
|
|
description = clean_html(get_element_by_id(
|
|
|
@ -106,10 +123,9 @@ class TwitCastingIE(InfoExtractor):
|
|
|
|
r'data-toggle="true"[^>]+datetime="([^"]+)"',
|
|
|
|
r'data-toggle="true"[^>]+datetime="([^"]+)"',
|
|
|
|
webpage, 'datetime', None))
|
|
|
|
webpage, 'datetime', None))
|
|
|
|
|
|
|
|
|
|
|
|
formats = None
|
|
|
|
|
|
|
|
if m3u8_url:
|
|
|
|
if m3u8_url:
|
|
|
|
formats = self._extract_m3u8_formats(
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
|
|
|
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', live=is_live)
|
|
|
|
m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', live=is_live))
|
|
|
|
self._sort_formats(formats)
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|