From 1151c4079a15939c981f3e30129b82dea1b1bc6d Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 19 Aug 2021 07:19:23 +0530 Subject: [extractor] Show video id in error messages if possible --- yt_dlp/extractor/common.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'yt_dlp/extractor/common.py') diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 85ac4857e..4e6deee1c 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -467,6 +467,13 @@ class InfoExtractor(object): def _match_id(cls, url): return cls._match_valid_url(url).group('id') + @classmethod + def get_temp_id(cls, url): + try: + return cls._match_id(url) + except (IndexError, AttributeError): + return None + @classmethod def working(cls): """Getter method for _WORKING.""" @@ -588,12 +595,14 @@ class InfoExtractor(object): if self.__maybe_fake_ip_and_retry(e.countries): continue raise - except ExtractorError: - raise + except ExtractorError as e: + video_id = e.video_id or self.get_temp_id(url) + raise ExtractorError( + e.msg, video_id=video_id, ie=self.IE_NAME, tb=e.traceback, expected=e.expected, cause=e.cause) except compat_http_client.IncompleteRead as e: - raise ExtractorError('A network error has occurred.', cause=e, expected=True) + raise ExtractorError('A network error has occurred.', cause=e, expected=True, video_id=self.get_temp_id(url)) except (KeyError, StopIteration) as e: - raise ExtractorError('An extractor error has occurred.', cause=e) + raise ExtractorError('An extractor error has occurred.', cause=e, video_id=self.get_temp_id(url)) def __maybe_fake_ip_and_retry(self, countries): if (not self.get_param('geo_bypass_country', None) -- cgit v1.2.3