From 3574d22de917edec9ca9d65a81f2f329bf9633d4 Mon Sep 17 00:00:00 2001 From: David Sn Date: Sat, 28 Mar 2020 19:42:42 +0100 Subject: [PATCH] [cda] Try to fix and improve extraction (fixes #24458) Signed-off-by: David Sn --- youtube_dl/extractor/cda.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/cda.py b/youtube_dl/extractor/cda.py index 0c3af23d5..b48501794 100644 --- a/youtube_dl/extractor/cda.py +++ b/youtube_dl/extractor/cda.py @@ -5,6 +5,7 @@ import codecs import re from .common import InfoExtractor +from ..compat import compat_urllib_parse_unquote from ..utils import ( ExtractorError, float_or_none, @@ -123,6 +124,19 @@ class CDAIE(InfoExtractor): 'age_limit': 18 if need_confirm_age else 0, } + def decrypt_file(file): + b = [] + + for ch in file: + f = ord(ch) + b.append(chr(33 + (f + 14) % 94) if 33 <= f and 126 >= f else chr(f)) + + return "".join(b) + + def decode(file): + decoded = codecs.decode(codecs.decode(file, "rot_13"), "rot_13") + return "https://" + decrypt_file(compat_urllib_parse_unquote(decoded)) + ".mp4" + def extract_format(page, version): json_str = self._html_search_regex( r'player_data=(\\?["\'])(?P.+?)\1', page, @@ -137,10 +151,9 @@ class CDAIE(InfoExtractor): if not video or 'file' not in video: self.report_warning('Unable to extract %s version information' % version) return - if video['file'].startswith('uggc'): - video['file'] = codecs.decode(video['file'], 'rot_13') - if video['file'].endswith('adc.mp4'): - video['file'] = video['file'].replace('adc.mp4', '.mp4') + video['file'] = decode(video['file']) + if video['file'].endswith('adc.mp4'): + video['file'] = video['file'].replace('adc.mp4', '.mp4') f = { 'url': video['file'], }