From 04a5e06350e3ef7c03f94f2f3f90dd96c6411152 Mon Sep 17 00:00:00 2001 From: sepro <4618135+seproDev@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:58:00 +0100 Subject: [PATCH] [ie/ondemandkorea] Fix upgraded format extraction (#8677) Closes #8675 Authored by: seproDev --- yt_dlp/extractor/ondemandkorea.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/yt_dlp/extractor/ondemandkorea.py b/yt_dlp/extractor/ondemandkorea.py index 81ce99fd9..94fcac720 100644 --- a/yt_dlp/extractor/ondemandkorea.py +++ b/yt_dlp/extractor/ondemandkorea.py @@ -3,7 +3,6 @@ import re import uuid from .common import InfoExtractor -from ..networking import HEADRequest from ..utils import ( ExtractorError, OnDemandPagedList, @@ -84,15 +83,17 @@ class OnDemandKoreaIE(InfoExtractor): def try_geo_bypass(url): return traverse_obj(url, ({parse_qs}, 'stream_url', 0, {url_or_none})) or url - def try_upgrade_quality(url): - mod_url = re.sub(r'_720(p?)\.m3u8', r'_1080\1.m3u8', url) - return mod_url if mod_url != url and self._request_webpage( - HEADRequest(mod_url), video_id, note='Checking for higher quality format', - errnote='No higher quality format found', fatal=False) else url - formats = [] for m3u8_url in traverse_obj(data, (('sources', 'manifest'), ..., 'url', {url_or_none}, {try_geo_bypass})): - formats.extend(self._extract_m3u8_formats(try_upgrade_quality(m3u8_url), video_id, fatal=False)) + mod_url = re.sub(r'_720(p?)\.m3u8', r'_1080\1.m3u8', m3u8_url) + if mod_url != m3u8_url: + mod_format = self._extract_m3u8_formats( + mod_url, video_id, note='Checking for higher quality format', + errnote='No higher quality format found', fatal=False) + if mod_format: + formats.extend(mod_format) + continue + formats.extend(self._extract_m3u8_formats(m3u8_url, video_id, fatal=False)) subtitles = {} for track in traverse_obj(data, ('text_tracks', lambda _, v: url_or_none(v['url']))):