mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
implement cookie validator
This commit is contained in:
parent
43eec5aac0
commit
9b107b9940
@ -6,6 +6,7 @@ functionality:
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import yt_dlp
|
||||||
from home.src.ta.config import AppConfig
|
from home.src.ta.config import AppConfig
|
||||||
from home.src.ta.ta_redis import RedisArchivist
|
from home.src.ta.ta_redis import RedisArchivist
|
||||||
|
|
||||||
@ -58,3 +59,21 @@ class CookieHandler:
|
|||||||
self.hide()
|
self.hide()
|
||||||
RedisArchivist().del_message(self.cookie_key)
|
RedisArchivist().del_message(self.cookie_key)
|
||||||
print("cookie: revoked")
|
print("cookie: revoked")
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
"""validate cookie using the liked videos playlist"""
|
||||||
|
_ = self.use()
|
||||||
|
url = "https://www.youtube.com/playlist?list=LL"
|
||||||
|
yt_obs = {
|
||||||
|
"quiet": True,
|
||||||
|
"skip_download": True,
|
||||||
|
"extract_flat": True,
|
||||||
|
"cookiefile": self.cookie_path,
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
response = yt_dlp.YoutubeDL(yt_obs).extract_info(url)
|
||||||
|
except yt_dlp.utils.DownloadError:
|
||||||
|
print("failed to validate cookie")
|
||||||
|
response = False
|
||||||
|
|
||||||
|
return bool(response)
|
||||||
|
Loading…
Reference in New Issue
Block a user