diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-08-06 03:47:11 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-08-07 21:17:05 +0530 |
commit | 28f436bad0597f1a471ae6d86a131d9cd24847f9 (patch) | |
tree | 213e4e42ac6155e576798f6d508a3d54c9c5fd1a | |
parent | 2b8a2973bde415fc227790275dfd3e55e43babae (diff) | |
download | hypervideo-pre-28f436bad0597f1a471ae6d86a131d9cd24847f9.tar.lz hypervideo-pre-28f436bad0597f1a471ae6d86a131d9cd24847f9.tar.xz hypervideo-pre-28f436bad0597f1a471ae6d86a131d9cd24847f9.zip |
[extractor] Reset non-repeating warnings per video
-rw-r--r-- | yt_dlp/extractor/common.py | 20 |
1 files 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 @@ class InfoExtractor(object): """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 @@ class InfoExtractor(object): 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 @@ class InfoExtractor(object): 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 @@ class InfoExtractor(object): 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 @@ class InfoExtractor(object): 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 @@ class InfoExtractor(object): 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 @@ class InfoExtractor(object): 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( |