From c3c1ccd7ab80852151fce2c10a9c39923d4aafe9 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Fri, 25 Jul 2025 23:15:43 +0300 Subject: [PATCH 01/11] refactor: compress ani-cli completions nushell provides convenient syntax for this --- .../ani-cli/ani-cli-completions.nu | 54 +++++++------------ 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 0c30c0772..c5e47d03a 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -14,38 +14,24 @@ def common_ranges [] { # Anime Search and Streaming Tool export extern "ani-cli" [ string? - -q: int@videoQuality # Specify video quality - --quality: int@videoQuality # Specify video quality - -s # Use Syncplay to watch with friends - --syncplay # Use Syncplay to watch with friends - -f # Use FZF for selection - --fzf # Use FZF for selection - -e: string@common_episodes # Specify episode number - --episode: string@common_episodes # Specify episode number - -d # Download the episode instead of playing it - --download # Download the episode instead of playing it - -p # Download episode to a specified directory - --path: string # Download episode to a specified directory - -c # Continue watching from history - --continue # Continue watching from history - -h # Show help text - --help # Show help text - -D # Delete history - --delete # Delete history - -l # Show logs - --log-view # Show logs - -U # Update the script - --update # Update the script - -V # Show the version of the script - --version # Show the version of the script - -r: string@common_ranges # Specify range number - --range: string@common_ranges # Specify range number - --skip # Use ani-skip to skip intros (mpv only) - --dub # Play dubbed version - --rofi # Use rofi instead of fzf for menu - --no-detach # Don't detach the player (mpv only) - --exit-after-play # Exit after playing (mpv only) - --skip-title: string # Use the given title for ani-skip query - -N # Display a countdown to the next episode - --nextep-countdown # Display a countdown to the next episode + --quality (-q): int@videoQuality # Specify video quality + --syncplay (-s) # Use Syncplay to watch with friends + --fzf (-f) # Use FZF for selection + --episode (-e): string@common_episodes # Specify episode number + --download (-d) # Download the episode instead of playing it + --path (-p): string # Download episode to a specified directory + --continue (-c) # Continue watching from history + --help (-h) # Show help text + --delete (-D) # Delete history + --log-view (-l) # Show logs + --update (-U) # Update the script + --version (-V) # Show the version of the script + --range (-r): string@common_ranges # Specify range number + --skip # Use ani-skip to skip intros (mpv only) + --dub # Play dubbed version + --rofi # Use rofi instead of fzf for menu + --no-detach # Don't detach the player (mpv only) + --exit-after-play # Exit after playing (mpv only) + --skip-title: string # Use the given title for ani-skip query + --nextep-countdown (-N) # Display a countdown to the next episode ] From bea404887b823f69e79007a8ace596b60f6b2872 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Fri, 25 Jul 2025 23:39:43 +0300 Subject: [PATCH 02/11] refactor: use correct nushell naming usage of words in plural is my liking, but camel case shouldn't be used anyway --- custom-completions/ani-cli/ani-cli-completions.nu | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index c5e47d03a..6646252c5 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -1,23 +1,23 @@ # author: HirschBerge # inspired by DWTW -def videoQuality [] { +def qualities [] { [ "worst", "360p", "480p", "720p", "1080p", "4K", "best" ] } -def common_episodes [] { +def episodes [] { [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13" ] } -def common_ranges [] { +def ranges [] { [ "1-5", "5-10", "1-13", "14-26", "1-26" ] } # Anime Search and Streaming Tool -export extern "ani-cli" [ +export extern ani-cli [ string? - --quality (-q): int@videoQuality # Specify video quality + --quality (-q): int@qualities # Specify video quality --syncplay (-s) # Use Syncplay to watch with friends --fzf (-f) # Use FZF for selection - --episode (-e): string@common_episodes # Specify episode number + --episode (-e): string@episodes # Specify episode number --download (-d) # Download the episode instead of playing it --path (-p): string # Download episode to a specified directory --continue (-c) # Continue watching from history @@ -26,7 +26,7 @@ export extern "ani-cli" [ --log-view (-l) # Show logs --update (-U) # Update the script --version (-V) # Show the version of the script - --range (-r): string@common_ranges # Specify range number + --range (-r): string@ranges # Specify range number --skip # Use ani-skip to skip intros (mpv only) --dub # Play dubbed version --rofi # Use rofi instead of fzf for menu From 33bce03c0d6a8999ff55710d7c80a37f760f7ae0 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 00:01:59 +0300 Subject: [PATCH 03/11] feat: change parameter comments styling of the parameters is done like the help menu of the ani-cli itself. imo it's more convenient to read and edit. also it's less than 80 symbols in width for the terminal. --- .../ani-cli/ani-cli-completions.nu | 80 ++++++++++++++----- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 6646252c5..3ecbd66dc 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -14,24 +14,64 @@ def ranges [] { # Anime Search and Streaming Tool export extern ani-cli [ string? - --quality (-q): int@qualities # Specify video quality - --syncplay (-s) # Use Syncplay to watch with friends - --fzf (-f) # Use FZF for selection - --episode (-e): string@episodes # Specify episode number - --download (-d) # Download the episode instead of playing it - --path (-p): string # Download episode to a specified directory - --continue (-c) # Continue watching from history - --help (-h) # Show help text - --delete (-D) # Delete history - --log-view (-l) # Show logs - --update (-U) # Update the script - --version (-V) # Show the version of the script - --range (-r): string@ranges # Specify range number - --skip # Use ani-skip to skip intros (mpv only) - --dub # Play dubbed version - --rofi # Use rofi instead of fzf for menu - --no-detach # Don't detach the player (mpv only) - --exit-after-play # Exit after playing (mpv only) - --skip-title: string # Use the given title for ani-skip query - --nextep-countdown (-N) # Display a countdown to the next episode + + --quality (-q): int@qualities + # Specify the video quality + + --syncplay (-s) + # Use Syncplay to watch with friends (mpv only) + + --fzf (-f) + # Use FZF for selection. + + --episode (-e): string@episodes + # Specify the episode number to watch + + --download (-d) + # Download the video instead of playing it + + --path (-p): string + # Download episode to a specified directory. + + --continue (-c) + # Continue watching from history + + --help (-h) + # Show summary of options + + --delete (-D) + # Delete history + + --log-view (-l) + # Show logs + + --update (-U) + # Update the script + + --version (-V) + # Show the version of the script + + --range (-r): string@ranges + # Specify the episode numbers to watch + + --skip + # Use ani-skip to skip the intro of the episode (mpv only) + + --dub + # Play the dubbed version + + --rofi + # Use rofi instead of fzf for the interactive menu + + --no-detach + # Don't detach the player (mpv only) + + --exit-after-play + # Exit after playing, and return player exit code (mpv only) + + --skip-title: string + # Use given title as ani-skip query + + --nextep-countdown (-N) + # Display a countdown to the next episode ] From de8f10d76a1ff869a64a30491a52daa80b827e1f Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 00:15:40 +0300 Subject: [PATCH 04/11] fix: remove/fix broken parameters some of them are just non-existent (i couldn't find them either in man page or help output). it's pretty important, because if the option doesn't exist, then the script will not output an error, but silently ignore it and use this option as the part of the query. --- custom-completions/ani-cli/ani-cli-completions.nu | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 3ecbd66dc..686bbd0b5 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -15,24 +15,18 @@ def ranges [] { export extern ani-cli [ string? - --quality (-q): int@qualities + --quality (-q): string@qualities # Specify the video quality --syncplay (-s) # Use Syncplay to watch with friends (mpv only) - --fzf (-f) - # Use FZF for selection. - --episode (-e): string@episodes # Specify the episode number to watch --download (-d) # Download the video instead of playing it - --path (-p): string - # Download episode to a specified directory. - --continue (-c) # Continue watching from history @@ -42,7 +36,7 @@ export extern ani-cli [ --delete (-D) # Delete history - --log-view (-l) + --logview (-l) # Show logs --update (-U) From 0810b6f25aa2d6767c7117c4a2b49c7a5fd114af Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 00:25:19 +0300 Subject: [PATCH 05/11] feat: add remaining parameters with that, change the command description to official man description. and add query parameter name. --- custom-completions/ani-cli/ani-cli-completions.nu | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 686bbd0b5..b2c603c7c 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -11,9 +11,14 @@ def ranges [] { [ "1-5", "5-10", "1-13", "14-26", "1-26" ] } -# Anime Search and Streaming Tool +# Watch anime from the commandline. +# +# A shell script to browse and search anime from the command-line. +# This tool scrapes the site allanime. +# ani-cli without options defaults to iina on macOS, flatpak mpv on Steamdeck, +# mpv apk on android, vlc on iOS and mpv media player everywhere else. export extern ani-cli [ - string? + query?: string --quality (-q): string@qualities # Specify the video quality @@ -68,4 +73,10 @@ export extern ani-cli [ --nextep-countdown (-N) # Display a countdown to the next episode + + --vlc (-v) + # Use VLC as the media player + + --select-nth (-S): int + # Selects nth entry ] From 2e29b6e0f50bf51e1ac8a28fd67132cf3a59acc2 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 00:29:06 +0300 Subject: [PATCH 06/11] style: rearrange parameters bring parameters with completions to the top for easy eye access for the functions. then non-boolean parameters and parameters with shorthand syntax. and everything else that remains. --- .../ani-cli/ani-cli-completions.nu | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index b2c603c7c..214abd0f6 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -23,12 +23,21 @@ export extern ani-cli [ --quality (-q): string@qualities # Specify the video quality - --syncplay (-s) - # Use Syncplay to watch with friends (mpv only) - --episode (-e): string@episodes # Specify the episode number to watch + --range (-r): string@ranges + # Specify the episode numbers to watch + + --select-nth (-S): int + # Selects nth entry + + --skip-title: string + # Use given title as ani-skip query + + --syncplay (-s) + # Use Syncplay to watch with friends (mpv only) + --download (-d) # Download the video instead of playing it @@ -50,8 +59,11 @@ export extern ani-cli [ --version (-V) # Show the version of the script - --range (-r): string@ranges - # Specify the episode numbers to watch + --nextep-countdown (-N) + # Display a countdown to the next episode + + --vlc (-v) + # Use VLC as the media player --skip # Use ani-skip to skip the intro of the episode (mpv only) @@ -67,16 +79,4 @@ export extern ani-cli [ --exit-after-play # Exit after playing, and return player exit code (mpv only) - - --skip-title: string - # Use given title as ani-skip query - - --nextep-countdown (-N) - # Display a countdown to the next episode - - --vlc (-v) - # Use VLC as the media player - - --select-nth (-S): int - # Selects nth entry ] From 8cf12ac9662484a2fbc4c0f894dfc2d1378d741c Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 00:42:12 +0300 Subject: [PATCH 07/11] docs: add description and change indent sorry to the previous contributors, but first comment is treated as the description for the module. also, contributors history can be viewed in the repository. as for the indent: sorry, but i like 4 spaces more. --- .../ani-cli/ani-cli-completions.nu | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 214abd0f6..1f1cdc95e 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -1,14 +1,15 @@ -# author: HirschBerge -# inspired by DWTW +# Custom completions for ani-cli 4.10.0 def qualities [] { - [ "worst", "360p", "480p", "720p", "1080p", "4K", "best" ] + [ "worst", "360p", "480p", "720p", "1080p", "4K", "best" ] } + def episodes [] { - [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13" ] + [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13" ] } + def ranges [] { - [ "1-5", "5-10", "1-13", "14-26", "1-26" ] + [ "1-5", "5-10", "1-13", "14-26", "1-26" ] } # Watch anime from the commandline. @@ -18,65 +19,65 @@ def ranges [] { # ani-cli without options defaults to iina on macOS, flatpak mpv on Steamdeck, # mpv apk on android, vlc on iOS and mpv media player everywhere else. export extern ani-cli [ - query?: string + query?: string - --quality (-q): string@qualities - # Specify the video quality + --quality (-q): string@qualities + # Specify the video quality - --episode (-e): string@episodes - # Specify the episode number to watch + --episode (-e): string@episodes + # Specify the episode number to watch - --range (-r): string@ranges - # Specify the episode numbers to watch + --range (-r): string@ranges + # Specify the episode numbers to watch - --select-nth (-S): int - # Selects nth entry + --select-nth (-S): int + # Selects nth entry - --skip-title: string - # Use given title as ani-skip query + --skip-title: string + # Use given title as ani-skip query - --syncplay (-s) - # Use Syncplay to watch with friends (mpv only) + --syncplay (-s) + # Use Syncplay to watch with friends (mpv only) - --download (-d) - # Download the video instead of playing it + --download (-d) + # Download the video instead of playing it - --continue (-c) - # Continue watching from history + --continue (-c) + # Continue watching from history - --help (-h) - # Show summary of options + --help (-h) + # Show summary of options - --delete (-D) - # Delete history + --delete (-D) + # Delete history - --logview (-l) - # Show logs + --logview (-l) + # Show logs - --update (-U) - # Update the script + --update (-U) + # Update the script - --version (-V) - # Show the version of the script + --version (-V) + # Show the version of the script - --nextep-countdown (-N) - # Display a countdown to the next episode + --nextep-countdown (-N) + # Display a countdown to the next episode - --vlc (-v) - # Use VLC as the media player + --vlc (-v) + # Use VLC as the media player - --skip - # Use ani-skip to skip the intro of the episode (mpv only) + --skip + # Use ani-skip to skip the intro of the episode (mpv only) - --dub - # Play the dubbed version + --dub + # Play the dubbed version - --rofi - # Use rofi instead of fzf for the interactive menu + --rofi + # Use rofi instead of fzf for the interactive menu - --no-detach - # Don't detach the player (mpv only) + --no-detach + # Don't detach the player (mpv only) - --exit-after-play - # Exit after playing, and return player exit code (mpv only) + --exit-after-play + # Exit after playing, and return player exit code (mpv only) ] From f786d813e3010a75f7654a41076b560848948da8 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 01:59:51 +0300 Subject: [PATCH 08/11] feat: advanced ani-cli completions maybe it's too much for a simple extern module for one command, and also not so good on performance, but i think a little bit of that extra functionality can be more useful --- .../ani-cli/ani-cli-completions.nu | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 1f1cdc95e..8a0c4e49e 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -1,16 +1,38 @@ # Custom completions for ani-cli 4.10.0 -def qualities [] { - [ "worst", "360p", "480p", "720p", "1080p", "4K", "best" ] -} - -def episodes [] { - [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13" ] -} +const qualities = [ + best + worst + '360' + '480' + '720' + '1080' +] -def ranges [] { - [ "1-5", "5-10", "1-13", "14-26", "1-26" ] -} +const limit = 24 + +def qualities [] { { + options: { sort: false } + completions: $qualities +} } + +def episodes [] { { + options: { sort: false } + completions: (1..$limit | into string) +} } + +def ranges [] { { + options: { sort: false } + completions: ( + 1..$limit | each { + |start| $start..$limit | each { + |end| if $start != $end { + $'($start)-($end)' + } + } + } | flatten + ) +} } # Watch anime from the commandline. # From 6f298cde6897f686a04d3fbc2626a71ed51db968 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 02:06:30 +0300 Subject: [PATCH 09/11] fix: wrapped query because ani-cli parses the query this way (found while making examples) --- custom-completions/ani-cli/ani-cli-completions.nu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 8a0c4e49e..e46996b29 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -41,7 +41,7 @@ def ranges [] { { # ani-cli without options defaults to iina on macOS, flatpak mpv on Steamdeck, # mpv apk on android, vlc on iOS and mpv media player everywhere else. export extern ani-cli [ - query?: string + ...query: string --quality (-q): string@qualities # Specify the video quality From 41b77c8e053a4d56ce48bfd19da7778736ee5918 Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 02:15:03 +0300 Subject: [PATCH 10/11] feat: add examples --- .../ani-cli/ani-cli-completions.nu | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index e46996b29..5d957b6da 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -40,6 +40,24 @@ def ranges [] { { # This tool scrapes the site allanime. # ani-cli without options defaults to iina on macOS, flatpak mpv on Steamdeck, # mpv apk on android, vlc on iOS and mpv media player everywhere else. +@example "Search for 'banana fish' in 720p" { + ani-cli -q 720 banana fish +} +@example "Search for 'one piece', select 2nd entry and skip the intro" { + ani-cli --skip --skip-title "one piece" -S 2 one piece +} +@example "Search for 'cyberpunk edgerunners' and download 2nd episode" { + ani-cli -d -e 2 cyberpunk edgerunners +} +@example "Search for 'cyberpunk edgerunners' 4th episode with VLC in 1080p" { + ani-cli --vlc cyberpunk edgerunners -q 1080 -e 4 +} +@example "Search for 'blue lock' 5th and 6th episodes" { + ani-cli blue lock -e 5-6 +} +@example "Search for 'blue lock' 5th and 6th episodes" { + ani-cli -e "5 6" blue lock +} export extern ani-cli [ ...query: string From d4c2ebeffd06a1716079dfaef45647629b60523e Mon Sep 17 00:00:00 2001 From: shimeoki Date: Sat, 26 Jul 2025 02:19:53 +0300 Subject: [PATCH 11/11] feat: add search terms and category --- custom-completions/ani-cli/ani-cli-completions.nu | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom-completions/ani-cli/ani-cli-completions.nu b/custom-completions/ani-cli/ani-cli-completions.nu index 5d957b6da..ea5921e2a 100644 --- a/custom-completions/ani-cli/ani-cli-completions.nu +++ b/custom-completions/ani-cli/ani-cli-completions.nu @@ -40,6 +40,8 @@ def ranges [] { { # This tool scrapes the site allanime. # ani-cli without options defaults to iina on macOS, flatpak mpv on Steamdeck, # mpv apk on android, vlc on iOS and mpv media player everywhere else. +@search-terms anime +@category network @example "Search for 'banana fish' in 720p" { ani-cli -q 720 banana fish }