Commit 88755d6f19
Unsigned
Layout: unified · split
curd.py +12
| @@ -20,6 +20,7 @@ import requests | ||
| 20 | 20 | import csv |
| 21 | 21 | import math |
| 22 | 22 | import socket |
| 23 | import urllib.parse | |
| 23 | 24 | # pypresence is also imported later if user enabled it in the config |
| 24 | 25 | |
| 25 | 26 | discord_client_id = "1287457464148820089" |
| @@ -1115,6 +1116,17 @@ if os.path.exists(access_token_path): | ||
| 1115 | 1116 | else: |
| 1116 | 1117 | print("Generate the token from https://anilist.co/api/v2/oauth/authorize?client_id=20686&response_type=token ") |
| 1117 | 1118 | 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) | |
| 1118 | 1130 | with open(access_token_path, "w") as token_file: |
| 1119 | 1131 | token_file.write(access_token) |
| 1120 | 1132 | print(f"Token saved to {access_token_path}") |