blob: 64a2814ada9f70018f48b1f36a83b73bd195f3a2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# Default to anime, permit manga
if [ "${args[--manga]}" = 1 ]; then
FORMAT="manga"
TYPE="manga"
FILTER="format"
elif [ "${args[--novel]}" = 1 ]; then
FORMAT="novel"
TYPE="manga"
FILTER="format"
elif [ "${args['--any-manga']}" = 1 ]; then
FORMAT="manga"
TYPE="manga"
FILTER="type"
else
FORMAT="tv"
TYPE="anime"
FILTER="format"
fi
TITLE=$(array_to_string "${args[title]}")
# Obtain media IDs from AniList
ID=$(curl 'https://graphql.anilist.co/' \
--silent \
--request POST \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data "{ \"query\": \"{ Media(search: \\\"${TITLE}\\\", \
${FILTER}: $(echo ${FORMAT} | tr '[:lower:]' '[:upper:]')) { id idMal } }\" }")
# Open the anime or manga in AniList by default, permit MyAnimeList
if [ "${args[--mal]}" = 1 ]; then
if [ "${args[--social]}" = 1 ]; then
FULL_URL=$(curl --silent \
"https://api.jikan.moe/v4/anime/$(echo "${ID}" |
jq '.data.Media.idMal')/full")
xdg-open "$(echo "${FULL_URL}" | jq -r '.data.url')/forum"
else
xdg-open https://myanimelist.net/${TYPE}/"$(echo "${ID}" | jq '.data.Media.idMal')"
fi
else
if [ "${args[--social]}" = 1 ]; then
xdg-open https://anilist.co/${TYPE}/"$(echo "${ID}" | jq '.data.Media.id')"/social
else
xdg-open https://anilist.co/${TYPE}/"$(echo "${ID}" | jq '.data.Media.id')"
fi
fi
|