Created
October 8, 2019 15:36
-
-
Save Der-Eddy/62b5597ad7d28921bcfe3ec73f2eb604 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import platform | |
import requests | |
oauthURL = 'https://anilist.co/api/v2/oauth/authorize?client_id=XXXX\&response_type=code' | |
api = 'https://graphql.anilist.co' | |
headers = {'user-agent': platform.system().lower() + ':anicli:v.1.0', 'Content-Type': 'application/json', 'Accept': 'application/json'} | |
accessToken = 'def50200a9891a ... currently hard coded for testing purposes' | |
if platform.system() == 'Linux' and not accessToken: | |
os.system(f'xdg-open {oauthURL}') | |
elif platform.system() == 'Windows' and not accessToken: | |
os.system(f'start {oauthURL}') | |
#accessToken = input() | |
query = ''' | |
query ($id: Int, $page: Int, $perPage: Int, $search: String) { | |
Page (page: $page, perPage: $perPage) { | |
pageInfo { | |
total | |
currentPage | |
lastPage | |
hasNextPage | |
perPage | |
} | |
media (id: $id, search: $search) { | |
id | |
title { | |
romaji | |
} | |
} | |
} | |
} | |
''' | |
variables = { | |
'search': 'Fate/Zero', | |
'page': 1, | |
'perPage': 3 | |
} | |
authHeaders = {'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json', 'Accept': 'application/json'} | |
auth = requests.post(api, headers=authHeaders, json={'query': query, 'variables': variables}) | |
print(auth.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment