Commit 6a435fba39
Unsigned
Layout: unified · split
curd.py +25 −1
| @@ -190,7 +190,30 @@ def add_anime_to_watching_list(anime_id: int, token: str): | ||
| 190 | 190 | else: |
| 191 | 191 | print(f"Failed to add anime. Status Code: {response.status_code}, Response: {response.text}") |
| 192 | 192 | |
| 193 | def get_anime_image(anilist_media_id): | |
| 193 | def get_anime_mal_id(anilist_media_id): | |
| 194 | url = "https://graphql.anilist.co" | |
| 195 | query = ''' | |
| 196 | query ($id: Int) { | |
| 197 | Media(id: $id) { | |
| 198 | idMal | |
| 199 | } | |
| 200 | } | |
| 201 | ''' | |
| 202 | variables = { | |
| 203 | 'id': anilist_media_id | |
| 204 | } | |
| 205 | ||
| 206 | # Make the API request | |
| 207 | response = requests.post(url, json={'query': query, 'variables': variables}) | |
| 208 | ||
| 209 | if response.status_code == 200: | |
| 210 | data = response.json() | |
| 211 | malId = data['data']['Media']['idMal'] | |
| 212 | return malId | |
| 213 | else: | |
| 214 | raise Exception(f"Failed to retrieve data from AniList API. Status Code: {response.status_code}") | |
| 215 | ||
| 216 | def get_anime_id_and_image(anilist_media_id): | |
| 194 | 217 | url = "https://graphql.anilist.co" |
| 195 | 218 | query = ''' |
| 196 | 219 | query ($id: Int) { |
| @@ -198,6 +221,7 @@ def get_anime_image(anilist_media_id): | ||
| 198 | 221 | coverImage { |
| 199 | 222 | large |
| 200 | 223 | } |
| 224 | idMal | |
| 201 | 225 | } |
| 202 | 226 | } |
| 203 | 227 | ''' |