[twitcasting] Fix extractor

* `Origin: https://twitcasting.tv` must be sent when requesting the webpage. Otherwise the extracted `m3u8` will always give a `502`
* Fix regex for when `data-movie-playlist` is a dict containing the needed list
* media initialization is fully supported; so change downloader to native

Closes #220
This commit is contained in:
pukkandan 2021-04-18 17:40:48 +05:30
parent b9d68c199b
commit d0491a1ebe
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -65,7 +65,9 @@ def _real_extract(self, url):
request_data = urlencode_postdata({ request_data = urlencode_postdata({
'password': video_password, 'password': video_password,
}) })
webpage = self._download_webpage(url, video_id, data=request_data) webpage = self._download_webpage(
url, video_id, data=request_data,
headers={'Origin': 'https://twitcasting.tv'})
title = clean_html(get_element_by_id( title = clean_html(get_element_by_id(
'movietitle', webpage)) or self._html_search_meta( 'movietitle', webpage)) or self._html_search_meta(
@ -77,14 +79,15 @@ def _real_extract(self, url):
webpage, 'm3u8 url', group='url', default=None) webpage, 'm3u8 url', group='url', default=None)
if not m3u8_url: if not m3u8_url:
video_js_data = self._parse_json(self._search_regex( video_js_data = self._parse_json(self._search_regex(
r"data-movie-playlist='(\[[^']+\])'", r'data-movie-playlist=(["\'])(?P<url>(?:(?!\1).)+)',
webpage, 'movie playlist'), video_id)[0] webpage, 'movie playlist', group='url'), video_id)
if isinstance(video_js_data, dict):
video_js_data = list(video_js_data.values())[0]
video_js_data = video_js_data[0]
m3u8_url = video_js_data['source']['url'] m3u8_url = video_js_data['source']['url']
# use `m3u8` entry_protocol until EXT-X-MAP is properly supported by `m3u8_native` entry_protocol
formats = self._extract_m3u8_formats( formats = self._extract_m3u8_formats(
m3u8_url, video_id, 'mp4', m3u8_id='hls') m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls')
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(
'authorcomment', webpage)) or self._html_search_meta( 'authorcomment', webpage)) or self._html_search_meta(