From bc7d90f1f4da09e17256c07347e336a1ce67deaf Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 30 Apr 2022 19:09:19 +0700 Subject: [PATCH] raise FileNotFoundError when trying to use unavailable cookie --- tubearchivist/home/src/download/yt_cookie.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tubearchivist/home/src/download/yt_cookie.py b/tubearchivist/home/src/download/yt_cookie.py index 0bb65e30..3b16ca56 100644 --- a/tubearchivist/home/src/download/yt_cookie.py +++ b/tubearchivist/home/src/download/yt_cookie.py @@ -36,6 +36,10 @@ class CookieHandler: def use(self): """make cookie available in FS""" cookie = RedisArchivist().get_message(self.COOKIE_KEY) + if isinstance(cookie, dict): + print("no cookie imported") + raise FileNotFoundError + with open(self.COOKIE_PATH, "w", encoding="utf-8") as cookie_file: cookie_file.write(cookie) @@ -60,7 +64,11 @@ class CookieHandler: def validate(self): """validate cookie using the liked videos playlist""" - _ = self.use() + try: + _ = self.use() + except FileNotFoundError: + return False + url = "https://www.youtube.com/playlist?list=LL" yt_obs = { "quiet": True,