From 28f436bad0597f1a471ae6d86a131d9cd24847f9 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 6 Aug 2021 03:47:11 +0530 Subject: [PATCH] [extractor] Reset non-repeating warnings per video --- yt_dlp/extractor/common.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 812e53d32..25b6dbc50 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -442,6 +442,7 @@ def __init__(self, downloader=None): """Constructor. Receives an optional downloader.""" self._ready = False self._x_forwarded_for_ip = None + self._printed_messages = set() self.set_downloader(downloader) @classmethod @@ -470,6 +471,7 @@ def working(cls): def initialize(self): """Initializes an instance (authentication, etc).""" + self._printed_messages = set() self._initialize_geo_bypass({ 'countries': self._GEO_COUNTRIES, 'ip_blocks': self._GEO_IP_BLOCKS, @@ -999,10 +1001,14 @@ def _download_socket_json( expected_status=expected_status) return res if res is False else res[0] - def report_warning(self, msg, video_id=None, *args, **kwargs): + def report_warning(self, msg, video_id=None, *args, only_once=False, **kwargs): idstr = '' if video_id is None else '%s: ' % video_id - self._downloader.report_warning( - '[%s] %s%s' % (self.IE_NAME, idstr, msg), *args, **kwargs) + msg = f'[{self.IE_NAME}] {idstr}{msg}' + if only_once: + if f'WARNING: {msg}' in self._printed_messages: + return + self._printed_messages.add(f'WARNING: {msg}') + self._downloader.report_warning(msg, *args, **kwargs) def to_screen(self, msg, *args, **kwargs): """Print msg to screen, prefixing it with '[ie_name]'""" @@ -1947,7 +1953,7 @@ def _extract_m3u8_formats(self, *args, **kwargs): self.report_warning(bug_reports_message( "Ignoring subtitle tracks found in the HLS manifest; " "if any subtitle tracks are missing," - )) + ), only_once=True) return fmts def _extract_m3u8_formats_and_subtitles( @@ -2230,7 +2236,7 @@ def _extract_smil_formats(self, *args, **kwargs): self.report_warning(bug_reports_message( "Ignoring subtitle tracks found in the SMIL manifest; " "if any subtitle tracks are missing," - )) + ), only_once=True) return fmts def _extract_smil_info(self, smil_url, video_id, fatal=True, f4m_params=None): @@ -2456,7 +2462,7 @@ def _extract_mpd_formats(self, *args, **kwargs): self.report_warning(bug_reports_message( "Ignoring subtitle tracks found in the DASH manifest; " "if any subtitle tracks are missing," - )) + ), only_once=True) return fmts def _extract_mpd_formats_and_subtitles( @@ -2483,7 +2489,7 @@ def _parse_mpd_formats(self, *args, **kwargs): self.report_warning(bug_reports_message( "Ignoring subtitle tracks found in the DASH manifest; " "if any subtitle tracks are missing," - )) + ), only_once=True) return fmts def _parse_mpd_formats_and_subtitles(