[extractor] Reset non-repeating warnings per video

This commit is contained in:
pukkandan 2021-08-06 03:47:11 +05:30
parent 2b8a2973bd
commit 28f436bad0

View File

@ -442,6 +442,7 @@ class InfoExtractor(object):
"""Constructor. Receives an optional downloader.""" """Constructor. Receives an optional downloader."""
self._ready = False self._ready = False
self._x_forwarded_for_ip = None self._x_forwarded_for_ip = None
self._printed_messages = set()
self.set_downloader(downloader) self.set_downloader(downloader)
@classmethod @classmethod
@ -470,6 +471,7 @@ class InfoExtractor(object):
def initialize(self): def initialize(self):
"""Initializes an instance (authentication, etc).""" """Initializes an instance (authentication, etc)."""
self._printed_messages = set()
self._initialize_geo_bypass({ self._initialize_geo_bypass({
'countries': self._GEO_COUNTRIES, 'countries': self._GEO_COUNTRIES,
'ip_blocks': self._GEO_IP_BLOCKS, 'ip_blocks': self._GEO_IP_BLOCKS,
@ -999,10 +1001,14 @@ class InfoExtractor(object):
expected_status=expected_status) expected_status=expected_status)
return res if res is False else res[0] 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 idstr = '' if video_id is None else '%s: ' % video_id
self._downloader.report_warning( msg = f'[{self.IE_NAME}] {idstr}{msg}'
'[%s] %s%s' % (self.IE_NAME, idstr, msg), *args, **kwargs) 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): def to_screen(self, msg, *args, **kwargs):
"""Print msg to screen, prefixing it with '[ie_name]'""" """Print msg to screen, prefixing it with '[ie_name]'"""
@ -1947,7 +1953,7 @@ class InfoExtractor(object):
self.report_warning(bug_reports_message( self.report_warning(bug_reports_message(
"Ignoring subtitle tracks found in the HLS manifest; " "Ignoring subtitle tracks found in the HLS manifest; "
"if any subtitle tracks are missing," "if any subtitle tracks are missing,"
)) ), only_once=True)
return fmts return fmts
def _extract_m3u8_formats_and_subtitles( def _extract_m3u8_formats_and_subtitles(
@ -2230,7 +2236,7 @@ class InfoExtractor(object):
self.report_warning(bug_reports_message( self.report_warning(bug_reports_message(
"Ignoring subtitle tracks found in the SMIL manifest; " "Ignoring subtitle tracks found in the SMIL manifest; "
"if any subtitle tracks are missing," "if any subtitle tracks are missing,"
)) ), only_once=True)
return fmts return fmts
def _extract_smil_info(self, smil_url, video_id, fatal=True, f4m_params=None): 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( self.report_warning(bug_reports_message(
"Ignoring subtitle tracks found in the DASH manifest; " "Ignoring subtitle tracks found in the DASH manifest; "
"if any subtitle tracks are missing," "if any subtitle tracks are missing,"
)) ), only_once=True)
return fmts return fmts
def _extract_mpd_formats_and_subtitles( def _extract_mpd_formats_and_subtitles(
@ -2483,7 +2489,7 @@ class InfoExtractor(object):
self.report_warning(bug_reports_message( self.report_warning(bug_reports_message(
"Ignoring subtitle tracks found in the DASH manifest; " "Ignoring subtitle tracks found in the DASH manifest; "
"if any subtitle tracks are missing," "if any subtitle tracks are missing,"
)) ), only_once=True)
return fmts return fmts
def _parse_mpd_formats_and_subtitles( def _parse_mpd_formats_and_subtitles(