diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bashly.yml | 9 | ||||
| -rw-r--r-- | src/character_command.sh | 13 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/bashly.yml b/src/bashly.yml index c3f106a..5615da6 100644 --- a/src/bashly.yml +++ b/src/bashly.yml @@ -45,6 +45,15 @@ commands: - long: --dub short: -d + - name: character + alias: c + dependencies: [xdg-open, curl, echo, jq] + + args: + - name: name + required: true + repeatable: true + - name: x dependencies: [xdg-open, curl, echo, tr, jq] diff --git a/src/character_command.sh b/src/character_command.sh new file mode 100644 index 0000000..7f2be39 --- /dev/null +++ b/src/character_command.sh @@ -0,0 +1,13 @@ +NAME=$(array_to_string "${args[name]}") + +# 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\": \"{ Character(search: \\\"${NAME}\\\") \ + { id } }\" }") + +xdg-open https://anilist.co/character/"$(echo "${ID}" | + jq '.data.Character.id' || true)" |