From fd76f28c6c9e91056a3196b549a2e8ed4a6ebd82 Mon Sep 17 00:00:00 2001 From: David Sn Date: Sun, 29 Mar 2020 12:25:53 +0200 Subject: [PATCH] [cda] Improve extraction and keep old method for legacy It is unknown whether CDA keeps using the old ROT13 decode method, as the original player.js code still contains the old method. Signed-off-by: David Sn --- youtube_dl/extractor/cda.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/cda.py b/youtube_dl/extractor/cda.py index b48501794..4b081a6f4 100644 --- a/youtube_dl/extractor/cda.py +++ b/youtube_dl/extractor/cda.py @@ -133,10 +133,6 @@ class CDAIE(InfoExtractor): 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, @@ -151,9 +147,14 @@ class CDAIE(InfoExtractor): if not video or 'file' not in video: self.report_warning('Unable to extract %s version information' % version) return - video['file'] = decode(video['file']) - if video['file'].endswith('adc.mp4'): - video['file'] = video['file'].replace('adc.mp4', '.mp4') + if "http" not in video['file'] and ".mp4" not in video['file'] and "uggcf://" not in video['file']: + video['file'] = decrypt_file(compat_urllib_parse_unquote(video['file'])) + if not video['file'].startswith("http"): + video['file'] = "https://" + video['file'] + ".mp4" + elif 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') f = { 'url': video['file'], }