mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-15 21:03:18 +00:00
[sponskrub] Better debug output and error message
This commit is contained in:
parent
43820c0370
commit
fbced7341d
|
@ -40,9 +40,10 @@ def pp_key(cls):
|
||||||
name = cls.__name__[:-2]
|
name = cls.__name__[:-2]
|
||||||
return compat_str(name[6:]) if name[:6].lower() == 'ffmpeg' else name
|
return compat_str(name[6:]) if name[:6].lower() == 'ffmpeg' else name
|
||||||
|
|
||||||
def to_screen(self, text, *args, **kwargs):
|
def to_screen(self, text, prefix=True, *args, **kwargs):
|
||||||
|
tag = '[%s] ' % self.PP_NAME if prefix else ''
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
return self._downloader.to_screen('[%s] %s' % (self.PP_NAME, text), *args, **kwargs)
|
return self._downloader.to_screen('%s%s' % (tag, text), *args, **kwargs)
|
||||||
|
|
||||||
def report_warning(self, text, *args, **kwargs):
|
def report_warning(self, text, *args, **kwargs):
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
|
@ -52,9 +53,10 @@ def report_error(self, text, *args, **kwargs):
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
return self._downloader.report_error(text, *args, **kwargs)
|
return self._downloader.report_error(text, *args, **kwargs)
|
||||||
|
|
||||||
def write_debug(self, text, *args, **kwargs):
|
def write_debug(self, text, prefix=True, *args, **kwargs):
|
||||||
|
tag = '[debug] ' if prefix else ''
|
||||||
if self.get_param('verbose', False):
|
if self.get_param('verbose', False):
|
||||||
return self._downloader.to_screen('[debug] %s' % text, *args, **kwargs)
|
return self._downloader.to_screen('%s%s' % (tag, text), *args, **kwargs)
|
||||||
|
|
||||||
def get_param(self, name, default=None, *args, **kwargs):
|
def get_param(self, name, default=None, *args, **kwargs):
|
||||||
if self._downloader:
|
if self._downloader:
|
||||||
|
|
|
@ -82,9 +82,8 @@ def run(self, information):
|
||||||
elif p.returncode == 3:
|
elif p.returncode == 3:
|
||||||
self.to_screen('No segments in the SponsorBlock database')
|
self.to_screen('No segments in the SponsorBlock database')
|
||||||
else:
|
else:
|
||||||
stderr = stderr.decode('utf-8', 'replace')
|
msg = stderr.decode('utf-8', 'replace').strip() or stdout.decode('utf-8', 'replace').strip()
|
||||||
msg = stderr.strip()
|
self.write_debug(msg, prefix=False)
|
||||||
if not self.get_param('verbose', False):
|
|
||||||
msg = msg.split('\n')[-1]
|
msg = msg.split('\n')[-1]
|
||||||
raise PostProcessingError(msg if msg else 'sponskrub failed with error code %s!' % p.returncode)
|
raise PostProcessingError(msg if msg else 'sponskrub failed with error code %s' % p.returncode)
|
||||||
return [], information
|
return [], information
|
||||||
|
|
Loading…
Reference in a new issue