diff options
| author | Fuwn <[email protected]> | 2023-07-28 22:32:10 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-07-28 22:32:10 -0700 |
| commit | 0a2fcddffc5b4b32ed772e02dd69afbe9734b0b1 (patch) | |
| tree | 6a8621b20b75acf9d9b5971dd10ea3e9d13ea81a /src/due/routes/anilist.py | |
| parent | refactor(manga): move rerequests to function (diff) | |
| download | old.due.moe-0a2fcddffc5b4b32ed772e02dd69afbe9734b0b1.tar.xz old.due.moe-0a2fcddffc5b4b32ed772e02dd69afbe9734b0b1.zip | |
feat(anilist): allow media increment
Diffstat (limited to 'src/due/routes/anilist.py')
| -rw-r--r-- | src/due/routes/anilist.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/due/routes/anilist.py b/src/due/routes/anilist.py new file mode 100644 index 0000000..63e1f7d --- /dev/null +++ b/src/due/routes/anilist.py @@ -0,0 +1,27 @@ +from flask import redirect, Blueprint, request +import requests +import json + +bp = Blueprint("anilist", __name__) + + [email protected]("/increment") +def increment_media(): + if request.cookies.get("anilist"): + anilist = json.loads(request.cookies.get("anilist")) + + return requests.post( + "https://graphql.anilist.co", + json={ + "query": f"""mutation {{ SaveMediaListEntry(mediaId: {request.args.get('id') or 30013}, progress: {request.args.get('progress') or 1}) {{ + id + }} }}""" + }, + headers={ + "Content-Type": "application/json", + "Accept": "application/json", + "Authorization": anilist["token_type"] + " " + anilist["access_token"], + }, + ).json() + + return redirect(request.headers.get("Referer") or "/") |