cinnamon-cli 0.2.19__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cinnamon/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.2.19"
cinnamon/anilist.py ADDED
@@ -0,0 +1,33 @@
1
+ import requests
2
+
3
+ API = "https://graphql.anilist.co"
4
+ UA = "cinnamon/0.1.0"
5
+
6
+ _SEARCH_QUERY = """
7
+ query ($search: String, $page: Int) {
8
+ Page(page: $page, perPage: 20) {
9
+ media(search: $search, type: ANIME) {
10
+ id
11
+ idMal
12
+ title { romaji english native }
13
+ episodes
14
+ status
15
+ format
16
+ startDate { year }
17
+ genres
18
+ }
19
+ }
20
+ }
21
+ """
22
+
23
+
24
+ def search_anime(query):
25
+ resp = requests.post(
26
+ API,
27
+ json={"query": _SEARCH_QUERY, "variables": {"search": query, "page": 1}},
28
+ timeout=15,
29
+ headers={"User-Agent": UA, "Content-Type": "application/json", "Accept": "application/json"},
30
+ )
31
+ resp.raise_for_status()
32
+ data = resp.json()
33
+ return data.get("data", {}).get("Page", {}).get("media", [])