Commit 88755d6f19

88755d6f1915c497fba50c20e9da18146a6b8309

parent: 3a45c73812

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-06 06:23 UTC

auto find access token

Layout: unified · split

curd.py +12
@@ -20,6 +20,7 @@ import requests
2020import csv
2121import math
2222import socket
23import urllib.parse
2324# pypresence is also imported later if user enabled it in the config
2425
2526discord_client_id = "1287457464148820089"
@@ -1115,6 +1116,17 @@ if os.path.exists(access_token_path):
11151116else:
11161117 print("Generate the token from https://anilist.co/api/v2/oauth/authorize?client_id=20686&response_type=token ")
11171118 access_token = input("Token file not found. Please generate and enter your token: ")
1119 if "https://" in access_token:
1120 # Parse the URL fragment part (after the `#`)
1121 fragment = urllib.parse.urlparse(access_token).fragment
1122
1123 # Parse the fragment into components
1124 params = urllib.parse.parse_qs(fragment)
1125
1126 # Extract only the access_token without any other parameters
1127 access_token = params['access_token'][0] if 'access_token' in params else None
1128
1129 print("Access Token:", access_token)
11181130 with open(access_token_path, "w") as token_file:
11191131 token_file.write(access_token)
11201132 print(f"Token saved to {access_token_path}")