This commit is contained in:
2025-02-08 08:56:19 -05:00
parent cc365970a9
commit c10c3a0beb
2 changed files with 42 additions and 5 deletions

View File

@@ -290,21 +290,20 @@ async def update_cookies(
cookie_data: CookieUpdate
):
try:
# see if cookie file exists
if not os.path.exists('cookies') and os.path.exists('cookies/tcg_cookies.json'):
logger.info("Cannot find cookies")
# Create cookies directory if it doesn't exist
os.makedirs('cookies', exist_ok=True)
# Save cookies with timestamp
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
cookie_path = f'cookies/tcg_cookies.json'
cookie_path = 'cookies/tcg_cookies.json'
# Save new cookies
with open(cookie_path, 'w') as f:
json.dump(cookie_data.cookies, f, indent=2)
# Update the "latest" cookies file
with open('cookies/tcg_cookies_latest.json', 'w') as f:
json.dump(cookie_data.cookies, f, indent=2)
return {"message": "Cookies updated successfully"}
except Exception as e: