mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
raise FileNotFoundError when trying to use unavailable cookie
This commit is contained in:
parent
3a21690309
commit
bc7d90f1f4
@ -36,6 +36,10 @@ class CookieHandler:
|
|||||||
def use(self):
|
def use(self):
|
||||||
"""make cookie available in FS"""
|
"""make cookie available in FS"""
|
||||||
cookie = RedisArchivist().get_message(self.COOKIE_KEY)
|
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:
|
with open(self.COOKIE_PATH, "w", encoding="utf-8") as cookie_file:
|
||||||
cookie_file.write(cookie)
|
cookie_file.write(cookie)
|
||||||
|
|
||||||
@ -60,7 +64,11 @@ class CookieHandler:
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
"""validate cookie using the liked videos playlist"""
|
"""validate cookie using the liked videos playlist"""
|
||||||
|
try:
|
||||||
_ = self.use()
|
_ = self.use()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False
|
||||||
|
|
||||||
url = "https://www.youtube.com/playlist?list=LL"
|
url = "https://www.youtube.com/playlist?list=LL"
|
||||||
yt_obs = {
|
yt_obs = {
|
||||||
"quiet": True,
|
"quiet": True,
|
||||||
|
Loading…
Reference in New Issue
Block a user