From 07da420536d784024aa1d5380e091cb1d6238636 Mon Sep 17 00:00:00 2001 From: camel2314 Date: Thu, 19 Jan 2023 22:52:59 -0500 Subject: [PATCH] fallback to non-encoded video_url in case of non-complete data --- youtube_dl/extractor/ktplayer.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/youtube_dl/extractor/ktplayer.py b/youtube_dl/extractor/ktplayer.py index d962dc5e7..be688ba60 100644 --- a/youtube_dl/extractor/ktplayer.py +++ b/youtube_dl/extractor/ktplayer.py @@ -198,6 +198,14 @@ class KtPlayerExtractor(InfoExtractor): height = int_or_none(res[:-1]) if height: default_format['height'] = height + else: + preview_height = self._html_search_regex( + r"""preview_height1:\s+'(.+?)'""", flashdata, 'preview_height', default=None, fatal=False) + if preview_height: + height = int_or_none(preview_height) + if height: + default_format['height'] = height + default_format['format_id'] = preview_height + 'p' formats = [default_format] video_alt_url = KtPlayerHelper.get_alt_url(flashdata) @@ -216,6 +224,14 @@ class KtPlayerExtractor(InfoExtractor): formats.append(alt_format) + if not ext and len(formats) == 1: + # this might indicate the decoded URL is not correct but the original URL might work + # add it into formats + formats.append({ + 'format_id': 'fallback', + 'url': KtPlayerHelper.get_raw_url(flashdata), + }) + description = self._og_search_title(webpage, fatal=False) duration = self._html_search_regex( self._DURATION_RE,