From b955e0a5dc208abaa5f7d64e7228c46bb8a3af63 Mon Sep 17 00:00:00 2001 From: vallovic Date: Sun, 21 Feb 2021 14:05:42 +0000 Subject: [PATCH] RTP devs like to try out different approaches --- youtube_dl/extractor/rtp.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/rtp.py b/youtube_dl/extractor/rtp.py index 02716c172..5ba26268e 100644 --- a/youtube_dl/extractor/rtp.py +++ b/youtube_dl/extractor/rtp.py @@ -15,11 +15,11 @@ import re class RTPIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?rtp\.pt/play/(.*\/)?p(?P[0-9]+)/(?P[^/?#]+)/?' + _VALID_URL = r'https?://(?:(?:(?:www\.)?rtp\.pt/play/(?P.*/)?p(?P[0-9]+)/(?Pe[0-9]+/)?)|(?:arquivos\.rtp\.pt/conteudos/))(?P[^/?#]+)/?' _TESTS = [{ 'url': 'https://www.rtp.pt/play/p117/e476527/os-contemporaneos', 'info_dict': { - 'id': 'e476527', + 'id': 'os-contemporaneos', 'ext': 'mp4', 'title': 'Os Contemporâneos Episódio 1 - RTP Play - RTP', 'description': 'Os Contemporâneos, um programa de humor com um olhar na sociedade portuguesa!', @@ -51,9 +51,12 @@ class RTPIE(InfoExtractor): # 1) The file URL is inside object and with HLS encoded... hls_encoded = re.match(r"[^[]*\[([^]]*)\]", stripped_line).groups()[0] hls_encoded = hls_encoded.replace('"', '').replace('\'', '').replace(',', '') - decoded_file_url = compat_b64decode( - compat_urllib_parse_unquote( - hls_encoded.replace('"', '').replace(',', ''))).decode('utf-8') + if 'atob' in stripped_line: + decoded_file_url = compat_b64decode( + compat_urllib_parse_unquote( + hls_encoded.replace('"', '').replace(',', ''))).decode('utf-8') + else: + decoded_file_url = compat_urllib_parse_unquote(hls_encoded) # Insert the decoded HLS file URL into pure JSON string json_string_for_config += '\nfile: "' + decoded_file_url + '",'