From 94aa064497122084c68f5f366c4c0ad5ea082485 Mon Sep 17 00:00:00 2001 From: Lesmiscore Date: Sun, 1 May 2022 00:38:30 +0900 Subject: [PATCH] [utils] YoutubeDLCookieJar: Detect and reject JSON file (#3599) Authored by: Lesmiscore --- yt_dlp/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 35426568b..3b75ab6b3 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -1507,6 +1507,10 @@ class YoutubeDLCookieJar(compat_cookiejar.MozillaCookieJar): try: cf.write(prepare_line(line)) except compat_cookiejar.LoadError as e: + if f'{line.strip()} '[0] in '[{"': + raise compat_cookiejar.LoadError( + 'Cookies file must be Netscape formatted, not JSON. See ' + 'https://github.com/ytdl-org/youtube-dl#how-do-i-pass-cookies-to-youtube-dl') write_string(f'WARNING: skipping cookie file entry due to {e}: {line!r}\n') continue cf.seek(0)