Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ie/openrec] add referer for m3u8 (fix #6946) #9253

Merged
merged 2 commits into from Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions yt_dlp/extractor/openrec.py
Expand Up @@ -12,6 +12,8 @@


class OpenRecBaseIE(InfoExtractor):
_M3U8_HEADERS = {'Referer': 'https://www.openrec.tv/'}

def _extract_pagestore(self, webpage, video_id):
return self._parse_json(
self._search_regex(r'(?m)window\.pageStore\s*=\s*(\{.+?\});$', webpage, 'window.pageStore'), video_id)
Expand All @@ -21,7 +23,7 @@ def _expand_media(self, video_id, media):
if not m3u8_url:
continue
yield from self._extract_m3u8_formats(
m3u8_url, video_id, ext='mp4', m3u8_id=name)
m3u8_url, video_id, ext='mp4', m3u8_id=name, headers=self._M3U8_HEADERS)

def _extract_movie(self, webpage, video_id, name, is_live):
window_stores = self._extract_pagestore(webpage, video_id)
Expand Down Expand Up @@ -60,6 +62,7 @@ def _extract_movie(self, webpage, video_id, name, is_live):
'uploader_id': get_first(movie_stores, ('channel', 'user', 'id')),
'timestamp': int_or_none(get_first(movie_stores, ['publishedAt', 'time']), scale=1000) or unified_timestamp(get_first(movie_stores, 'publishedAt')),
'is_live': is_live,
'http_headers': self._M3U8_HEADERS,
}


Expand Down Expand Up @@ -110,7 +113,7 @@ def _real_extract(self, url):
raise ExtractorError('Cannot extract title')

formats = self._extract_m3u8_formats(
capture_data.get('source'), video_id, ext='mp4')
capture_data.get('source'), video_id, ext='mp4', headers=self._M3U8_HEADERS)

return {
'id': video_id,
Expand All @@ -121,6 +124,7 @@ def _real_extract(self, url):
'uploader': traverse_obj(movie_store, ('channel', 'name'), expected_type=compat_str),
'uploader_id': traverse_obj(movie_store, ('channel', 'id'), expected_type=compat_str),
'upload_date': unified_strdate(capture_data.get('createdAt')),
'http_headers': self._M3U8_HEADERS,
}


Expand Down