[openrec] Download archived livestreams (#3267)
Authored by: Lesmiscore
This commit is contained in:
parent
fbfde1c3e6
commit
265e586d96
1 changed files with 23 additions and 7 deletions
|
@ -7,6 +7,7 @@ from ..utils import (
|
||||||
get_first,
|
get_first,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
|
try_get,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
unified_timestamp,
|
unified_timestamp,
|
||||||
)
|
)
|
||||||
|
@ -18,6 +19,13 @@ class OpenRecBaseIE(InfoExtractor):
|
||||||
return self._parse_json(
|
return self._parse_json(
|
||||||
self._search_regex(r'(?m)window\.pageStore\s*=\s*(\{.+?\});$', webpage, 'window.pageStore'), video_id)
|
self._search_regex(r'(?m)window\.pageStore\s*=\s*(\{.+?\});$', webpage, 'window.pageStore'), video_id)
|
||||||
|
|
||||||
|
def _expand_media(self, video_id, media):
|
||||||
|
for name, m3u8_url in (media or {}).items():
|
||||||
|
if not m3u8_url:
|
||||||
|
continue
|
||||||
|
yield from self._extract_m3u8_formats(
|
||||||
|
m3u8_url, video_id, ext='mp4', m3u8_id=name)
|
||||||
|
|
||||||
def _extract_movie(self, webpage, video_id, name, is_live):
|
def _extract_movie(self, webpage, video_id, name, is_live):
|
||||||
window_stores = self._extract_pagestore(webpage, video_id)
|
window_stores = self._extract_pagestore(webpage, video_id)
|
||||||
movie_stores = [
|
movie_stores = [
|
||||||
|
@ -29,13 +37,21 @@ class OpenRecBaseIE(InfoExtractor):
|
||||||
if not any(movie_stores):
|
if not any(movie_stores):
|
||||||
raise ExtractorError(f'Failed to extract {name} info')
|
raise ExtractorError(f'Failed to extract {name} info')
|
||||||
|
|
||||||
m3u8_playlists = get_first(movie_stores, 'media') or {}
|
formats = list(self._expand_media(video_id, get_first(movie_stores, 'media')))
|
||||||
formats = []
|
if not formats and is_live:
|
||||||
for name, m3u8_url in m3u8_playlists.items():
|
# archived livestreams
|
||||||
if not m3u8_url:
|
cookies = self._get_cookies('https://www.openrec.tv/')
|
||||||
continue
|
detail = self._download_json(
|
||||||
formats.extend(self._extract_m3u8_formats(
|
f'https://apiv5.openrec.tv/api/v5/movies/{video_id}/detail', video_id,
|
||||||
m3u8_url, video_id, ext='mp4', live=is_live, m3u8_id=name))
|
headers={
|
||||||
|
'Origin': 'https://www.openrec.tv',
|
||||||
|
'Referer': 'https://www.openrec.tv/',
|
||||||
|
'access-token': try_get(cookies, lambda x: x.get('access_token').value),
|
||||||
|
'uuid': try_get(cookies, lambda x: x.get('uuid').value),
|
||||||
|
})
|
||||||
|
new_media = traverse_obj(detail, ('data', 'items', ..., 'media'), get_all=False)
|
||||||
|
formats = list(self._expand_media(video_id, new_media))
|
||||||
|
is_live = False
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue