aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/YoutubeDL.py
diff options
context:
space:
mode:
authorSimon Sawicki <contact@grub4k.xyz>2024-10-01 02:13:48 +0200
committerGitHub <noreply@github.com>2024-10-01 02:13:48 +0200
commite59c82a74cda5139eb3928c75b0bd45484dbe7f0 (patch)
treef41b6eae79ece0d67f141710fb6e51f1f0baaabd /yt_dlp/YoutubeDL.py
parentf91645aceaf13926cf35be2c1dfef61b3aab97fb (diff)
[cookies] Fix cookie load error handling (#11140)
Authored by: Grub4K
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r--yt_dlp/YoutubeDL.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 9691a1ea7..4f45d7faf 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -27,7 +27,7 @@ import unicodedata
from .cache import Cache
from .compat import urllib # isort: split
from .compat import compat_os_name, urllib_req_to_req
-from .cookies import LenientSimpleCookie, load_cookies
+from .cookies import CookieLoadError, LenientSimpleCookie, load_cookies
from .downloader import FFmpegFD, get_suitable_downloader, shorten_protocol_name
from .downloader.rtmp import rtmpdump_version
from .extractor import gen_extractor_classes, get_info_extractor
@@ -1624,7 +1624,7 @@ class YoutubeDL:
while True:
try:
return func(self, *args, **kwargs)
- except (DownloadCancelled, LazyList.IndexError, PagedList.IndexError):
+ except (CookieLoadError, DownloadCancelled, LazyList.IndexError, PagedList.IndexError):
raise
except ReExtractInfo as e:
if e.expected:
@@ -3580,6 +3580,8 @@ class YoutubeDL:
def wrapper(*args, **kwargs):
try:
res = func(*args, **kwargs)
+ except CookieLoadError:
+ raise
except UnavailableVideoError as e:
self.report_error(e)
except DownloadCancelled as e:
@@ -4113,8 +4115,13 @@ class YoutubeDL:
@functools.cached_property
def cookiejar(self):
"""Global cookiejar instance"""
- return load_cookies(
- self.params.get('cookiefile'), self.params.get('cookiesfrombrowser'), self)
+ try:
+ return load_cookies(
+ self.params.get('cookiefile'), self.params.get('cookiesfrombrowser'), self)
+ except CookieLoadError as error:
+ cause = error.__context__
+ self.report_error(str(cause), tb=''.join(traceback.format_exception(cause)))
+ raise
@property
def _opener(self):