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