diff options
| author | Fuwn <[email protected]> | 2023-07-15 22:01:34 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-07-15 22:01:34 -0700 |
| commit | 9c3068e61d4b4dd6543d793442dcda97f7a34a66 (patch) | |
| tree | 2379b105e62dae97b481401291f5d5e98454d732 /src | |
| download | kaguya-9c3068e61d4b4dd6543d793442dcda97f7a34a66.tar.xz kaguya-9c3068e61d4b4dd6543d793442dcda97f7a34a66.zip | |
feat: initial release
Diffstat (limited to 'src')
| -rw-r--r-- | src/anichart_command.sh | 1 | ||||
| -rw-r--r-- | src/anilist_command.sh | 5 | ||||
| -rw-r--r-- | src/bashly.yml | 51 | ||||
| -rw-r--r-- | src/crunchyroll_command.sh | 5 | ||||
| -rw-r--r-- | src/hidive_command.sh | 5 | ||||
| -rw-r--r-- | src/lib/array_to_string.sh | 5 | ||||
| -rw-r--r-- | src/myanimelist_command.sh | 5 | ||||
| -rw-r--r-- | src/x_command.sh | 28 |
8 files changed, 105 insertions, 0 deletions
diff --git a/src/anichart_command.sh b/src/anichart_command.sh new file mode 100644 index 0000000..6b84ebb --- /dev/null +++ b/src/anichart_command.sh @@ -0,0 +1 @@ +xdg-open https://anichart.net/ diff --git a/src/anilist_command.sh b/src/anilist_command.sh new file mode 100644 index 0000000..40e5018 --- /dev/null +++ b/src/anilist_command.sh @@ -0,0 +1,5 @@ +if [ -n "${args[profile]}" ]; then + xdg-open https://anilist.co/user/"${args[profile]}" +else + xdg-open https://anilist.co/home +fi diff --git a/src/bashly.yml b/src/bashly.yml new file mode 100644 index 0000000..3a0882b --- /dev/null +++ b/src/bashly.yml @@ -0,0 +1,51 @@ +name: kaguya +help: Fuwn's Anime & Manga Utility +version: 0.1.0 + +commands: + - name: anichart + alias: ac + + - name: myanimelist + alias: mal + args: + - name: profile + + - name: anilist + alias: al + args: + - name: profile + + - name: crunchyroll + alias: cr + args: + - name: search + repeatable: true + + - name: hidive + alias: hd + args: + - name: search + repeatable: true + + - name: x + args: + - name: title + required: true + repeatable: true + + flags: + - long: --anime + conflicts: [--manga] + + - long: --manga + conflicts: [--anime] + + - long: --al + conflicts: [--mal] + + - long: --mal + conflicts: [--al] + + - long: --social + short: -s diff --git a/src/crunchyroll_command.sh b/src/crunchyroll_command.sh new file mode 100644 index 0000000..c80bcf6 --- /dev/null +++ b/src/crunchyroll_command.sh @@ -0,0 +1,5 @@ +if [ -n "${args[search]}" ]; then + xdg-open https://www.crunchyroll.com/search?q="$(array_to_string "${args[search]}")" +else + xdg-open https://www.crunchyroll.com/ +fi diff --git a/src/hidive_command.sh b/src/hidive_command.sh new file mode 100644 index 0000000..d3025df --- /dev/null +++ b/src/hidive_command.sh @@ -0,0 +1,5 @@ +if [ -n "${args[search]}" ]; then + xdg-open https://www.hidive.com/search?q="$(array_to_string "${args[search]}")" +else + xdg-open https://www.hidive.com/ +fi diff --git a/src/lib/array_to_string.sh b/src/lib/array_to_string.sh new file mode 100644 index 0000000..7d3b0c6 --- /dev/null +++ b/src/lib/array_to_string.sh @@ -0,0 +1,5 @@ +array_to_string() { + array="${1}" + + echo "${array[*]// / }" | tr -d '"' +} diff --git a/src/myanimelist_command.sh b/src/myanimelist_command.sh new file mode 100644 index 0000000..e372c04 --- /dev/null +++ b/src/myanimelist_command.sh @@ -0,0 +1,5 @@ +if [ -n "${args[profile]}" ]; then + xdg-open https://myanimelist.net/profile/"${args[profile]}" +else + xdg-open https://myanimelist.net +fi diff --git a/src/x_command.sh b/src/x_command.sh new file mode 100644 index 0000000..4150cdb --- /dev/null +++ b/src/x_command.sh @@ -0,0 +1,28 @@ +# Default to anime, permit manga +if [ "${args[--manga]}" = 1 ]; then + TYPE="manga" +else + TYPE="anime" +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}\\\", \ + type: $(echo ${TYPE} | tr '[:lower:]' '[:upper:]')) { id idMal } }\" }") + +# Open the anime or manga in AniList by default, permit MyAnimeList +if [ "${args[--mal]}" = 1 ]; then + xdg-open https://myanimelist.net/${TYPE}/"$(echo "${ID}" | jq '.data.Media.idMal')" +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 |