aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-09-22 01:37:44 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-09-22 02:15:55 +0530
commit2fa669f759eae6d5c7e608e3ee628f9d60d03e83 (patch)
treea994bb325804ed528c04208a928cd5830ee81126 /yt_dlp/utils.py
parent8ca48a1a5427040fd708f33a264c10d5d0e85fc1 (diff)
downloadhypervideo-pre-2fa669f759eae6d5c7e608e3ee628f9d60d03e83.tar.lz
hypervideo-pre-2fa669f759eae6d5c7e608e3ee628f9d60d03e83.tar.xz
hypervideo-pre-2fa669f759eae6d5c7e608e3ee628f9d60d03e83.zip
[docs] Misc improvements
Closes #4987, Closes #4906, Closes #4919, Closes #4977, Closes #4979
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))