[rtp] Thwart latest fingerprinting attempt

This commit is contained in:
felix 2022-04-24 13:38:06 +02:00
parent 96b49af01c
commit 7e6a4cb3dc
1 changed files with 22 additions and 2 deletions

View File

@ -29,6 +29,17 @@ class RTPIE(InfoExtractor):
\s*\.\s*join\(\s*(?:""|'')\s*\)\s*\)\s*\)
''')
__HEADERS = {
'Referer': 'https://www.rtp.pt/',
'Origin': 'https://www.rtp.pt',
'Accept': '*/*',
'Accept-Language': 'pt,en-US;q=0.7,en;q=0.3',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Sec-GPC': '1',
}
def __unobfuscate(self, data, *, video_id):
if data.startswith('{'):
data = self._RX_OBFUSCATION.sub(
@ -65,16 +76,25 @@ class RTPIE(InfoExtractor):
f_hls = f.get('hls')
if f_hls is not None:
formats.extend(self._extract_m3u8_formats(
f_hls, video_id, 'mp4', 'm3u8_native', m3u8_id='hls'))
f_hls, video_id, 'mp4', 'm3u8_native', m3u8_id='hls',
headers=self.__HEADERS))
f_dash = f.get('dash')
if f_dash is not None:
formats.extend(self._extract_mpd_formats(f_dash, video_id, mpd_id='dash'))
formats.extend(self._extract_mpd_formats(
f_dash, video_id, mpd_id='dash',
headers=self.__HEADERS))
for fmt in formats:
fmt.update({
'http_headers': self.__HEADERS,
})
else:
formats.append({
'format_id': 'f',
'url': f,
'vcodec': 'none' if config.get('mediaType') == 'audio' else None,
'http_headers': self.__HEADERS,
})
subtitles = {}