update headers

This commit is contained in:
c-basalt 2024-10-07 12:47:47 -04:00
parent 9d4497e13e
commit 501c9d5267

View File

@ -60,10 +60,19 @@ def requestor_query(self):
@property @property
def jwt_header(self): def jwt_header(self):
return { return {
'Origin': 'https://rplay.live',
'Referer': 'https://rplay.live/', 'Referer': 'https://rplay.live/',
'Authorization': self.jwt_token or 'null', 'Authorization': self.jwt_token or 'null',
} }
@property
def butter_header(self):
return {
'Origin': 'https://rplay.live',
'Referer': 'https://rplay.live/',
'Butter': self.get_butter_token(),
}
def _login_hint(self, **kwargs): def _login_hint(self, **kwargs):
return (f'Use --username and --password, --netrc-cmd, --netrc ({self._NETRC_MACHINE}) ' return (f'Use --username and --password, --netrc-cmd, --netrc ({self._NETRC_MACHINE}) '
'or --extractor-args "rplaylive:jwt_token=xxx" to provide account credentials') 'or --extractor-args "rplaylive:jwt_token=xxx" to provide account credentials')
@ -201,15 +210,14 @@ def _real_extract(self, url):
msg += f'. {self._login_hint()}' msg += f'. {self._login_hint()}'
raise ExtractorError(msg, expected=True) raise ExtractorError(msg, expected=True)
formats = self._extract_m3u8_formats(m3u8_url, video_id, headers={ formats = self._extract_m3u8_formats(m3u8_url, video_id, headers=self.butter_header)
'Referer': 'https://rplay.live/', 'Butter': self.get_butter_token()})
for fmt in formats: for fmt in formats:
m3u8_doc = self._download_webpage(fmt['url'], video_id, 'getting m3u8 contents', headers={ m3u8_doc = self._download_webpage(fmt['url'], video_id, 'getting m3u8 contents', headers=self.butter_header)
'Referer': 'https://rplay.live/', 'Butter': self.get_butter_token()})
fmt['url'] = encode_data_uri(m3u8_doc.encode(), 'application/x-mpegurl') fmt['url'] = encode_data_uri(m3u8_doc.encode(), 'application/x-mpegurl')
match = re.search(r'^#EXT-X-KEY.*?URI="([^"]+)"', m3u8_doc, flags=re.M) match = re.search(r'^#EXT-X-KEY.*?URI="([^"]+)"', m3u8_doc, flags=re.M)
if match: if match:
urlh = self._request_webpage(match[1], video_id, 'getting hls key', headers={ urlh = self._request_webpage(match[1], video_id, 'getting hls key', headers={
'Origin': 'https://rplay.live',
'Referer': 'https://rplay.live/', 'Referer': 'https://rplay.live/',
'rplay-private-content-requestor': self.user_id or 'not-logged-in', 'rplay-private-content-requestor': self.user_id or 'not-logged-in',
'age': random.randint(1, 4999), 'age': random.randint(1, 4999),