aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 443c49814..26ef3c7dd 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -591,9 +591,14 @@ class LenientJSONDecoder(json.JSONDecoder):
def decode(self, s):
if self.transform_source:
s = self.transform_source(s)
- if self.ignore_extra:
- return self.raw_decode(s.lstrip())[0]
- return super().decode(s)
+ try:
+ if self.ignore_extra:
+ return self.raw_decode(s.lstrip())[0]
+ return super().decode(s)
+ except json.JSONDecodeError as e:
+ if e.pos is not None:
+ raise type(e)(f'{e.msg} in {s[e.pos-10:e.pos+10]!r}', s, e.pos)
+ raise
def sanitize_open(filename, open_mode):
@@ -762,7 +767,7 @@ def sanitized_Request(url, *args, **kwargs):
def expand_path(s):
- """Expand $ shell variables and ~"""
+ """Expand shell variables and ~"""
return os.path.expandvars(compat_expanduser(s))