mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-09-06 02:49:35 +02:00
InfoExtractor._search_regex: Suggest updating when the regex is not found (suggested in #5442)
Reuse the same message from ExtractorError
This commit is contained in:
parent
3220c50f9a
commit
08f2a92c9c
@ -23,6 +23,7 @@
|
|||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
age_restricted,
|
age_restricted,
|
||||||
|
bug_reports_message,
|
||||||
clean_html,
|
clean_html,
|
||||||
compiled_regex_type,
|
compiled_regex_type,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
@ -556,8 +557,7 @@ def _search_regex(self, pattern, string, name, default=_NO_DEFAULT, fatal=True,
|
|||||||
elif fatal:
|
elif fatal:
|
||||||
raise RegexNotFoundError('Unable to extract %s' % _name)
|
raise RegexNotFoundError('Unable to extract %s' % _name)
|
||||||
else:
|
else:
|
||||||
self._downloader.report_warning('unable to extract %s; '
|
self._downloader.report_warning('unable to extract %s' % _name + bug_reports_message())
|
||||||
'please report this issue on http://yt-dl.org/bug' % _name)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _html_search_regex(self, pattern, string, name, default=_NO_DEFAULT, fatal=True, flags=0, group=None):
|
def _html_search_regex(self, pattern, string, name, default=_NO_DEFAULT, fatal=True, flags=0, group=None):
|
||||||
|
@ -452,6 +452,17 @@ def make_HTTPS_handler(params, **kwargs):
|
|||||||
return YoutubeDLHTTPSHandler(params, context=context, **kwargs)
|
return YoutubeDLHTTPSHandler(params, context=context, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def bug_reports_message():
|
||||||
|
if ytdl_is_updateable():
|
||||||
|
update_cmd = 'type youtube-dl -U to update'
|
||||||
|
else:
|
||||||
|
update_cmd = 'see https://yt-dl.org/update on how to update'
|
||||||
|
msg = '; please report this issue on https://yt-dl.org/bug .'
|
||||||
|
msg += ' Make sure you are using the latest version; %s.' % update_cmd
|
||||||
|
msg += ' Be sure to call youtube-dl with the --verbose flag and include its complete output.'
|
||||||
|
return msg
|
||||||
|
|
||||||
|
|
||||||
class ExtractorError(Exception):
|
class ExtractorError(Exception):
|
||||||
"""Error during info extraction."""
|
"""Error during info extraction."""
|
||||||
|
|
||||||
@ -467,13 +478,7 @@ def __init__(self, msg, tb=None, expected=False, cause=None, video_id=None):
|
|||||||
if cause:
|
if cause:
|
||||||
msg += ' (caused by %r)' % cause
|
msg += ' (caused by %r)' % cause
|
||||||
if not expected:
|
if not expected:
|
||||||
if ytdl_is_updateable():
|
msg += bug_reports_message()
|
||||||
update_cmd = 'type youtube-dl -U to update'
|
|
||||||
else:
|
|
||||||
update_cmd = 'see https://yt-dl.org/update on how to update'
|
|
||||||
msg += '; please report this issue on https://yt-dl.org/bug .'
|
|
||||||
msg += ' Make sure you are using the latest version; %s.' % update_cmd
|
|
||||||
msg += ' Be sure to call youtube-dl with the --verbose flag and include its complete output.'
|
|
||||||
super(ExtractorError, self).__init__(msg)
|
super(ExtractorError, self).__init__(msg)
|
||||||
|
|
||||||
self.traceback = tb
|
self.traceback = tb
|
||||||
|
Loading…
Reference in New Issue
Block a user