Skip to content

Commit

Permalink
feat: added support for ani-skip to skip episode intros (pystardust#1231
Browse files Browse the repository at this point in the history
)

Co-authored-by: Aaron Züger <[email protected]>
  • Loading branch information
2 people authored and PhosCity committed Dec 7, 2023
1 parent 4c25249 commit bb5bbb1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sudo rm "/usr/local/bin/ani-cli"
- fzf - User interface
- trackma (Optional)
- rofi (Optional)

- ani-skip (optional)

## Homies

Expand Down
12 changes: 9 additions & 3 deletions ani-cli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

version_number="4.6.2"
version_number="4.7.0"

# USER VARIABLES
rofi_config="${HOME}/.config/rofi/ani-cli.rasi"
Expand Down Expand Up @@ -73,6 +73,8 @@ help_info() {
Play dubbed version
--rofi
Use rofi instead of fzf for the interactive menu
--skip
Use ani-skip to skip the intro of the episode (mpv only)
-U, --update
Update the script
Some example usages:
Expand Down Expand Up @@ -247,14 +249,15 @@ download() {
}

play_episode() {
[ "$skip_intro" = 1 ] && skip_flag="$(ani-skip "$title" "$ep_no")"
[ -z "$episode" ] && get_episode_url
# shellcheck disable=SC2086
case "$player_function" in
debug)
[ -z "$ANI_CLI_NON_INTERACTIVE" ] && printf "All links:\n%s\nSelected link:\n" "$links"
printf "%s\n" "$episode"
;;

mpv*) nohup "$player_function" --force-media-title="${allanime_title}Episode ${ep_no}" "$episode" >/dev/null 2>&1 & ;;
mpv*) nohup "$player_function" $skip_flag --force-media-title="${allanime_title}Episode ${ep_no}" "$episode" >/dev/null 2>&1 & ;;
android_mpv) nohup am start --user 0 -a android.intent.action.VIEW -d "$episode" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 & ;;
android_vlc) nohup am start --user 0 -a android.intent.action.VIEW -d "$episode" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "${allanime_title}Episode ${ep_no}" >/dev/null 2>&1 & ;;
iina) nohup "$player_function" --no-stdin --keep-running --mpv-force-media-title="${allanime_title}Episode ${ep_no}" "$episode" >/dev/null 2>&1 & ;;
Expand Down Expand Up @@ -351,6 +354,7 @@ case "$(uname -a)" in
esac

use_external_menu="${ANI_CLI_EXTERNAL_MENU:-0}"
skip_intro="${ANI_CLI_SKIP_INTRO:-0}"
[ -t 0 ] || use_external_menu=1
hist_dir="${ANI_CLI_HIST_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/ani-cli}"
[ ! -d "$hist_dir" ] && mkdir -p "$hist_dir"
Expand Down Expand Up @@ -409,6 +413,7 @@ while [ $# -gt 0 ]; do
-t | --trackma) use_trackma=1 ;;
--dub) mode="dub" ;;
--rofi) use_external_menu=1 ;;
--skip) skip_intro=1 ;;
-U | --update) update_script ;;
*) query="$(printf "%s" "$query $1" | sed "s|^ ||;s| |+|g")" ;;
esac
Expand All @@ -418,6 +423,7 @@ done
[ "$use_external_menu" = "1" ] && multi_selection_flag="${ANI_CLI_MULTI_SELECTION:-"-multi-select"}"
printf "\33[2K\r\033[1;34mChecking dependencies...\033\n[0m"
dep_ch "curl" "sed" "grep" || true
[ "$skip_intro" = 1 ] && (dep_ch "ani-skip" || true)
if [ -z "$ANI_CLI_NON_INTERACTIVE" ]; then dep_ch fzf || true; fi
[ "${use_external_menu}" -eq 1 ] && dep_ch "rofi"
[ "${use_trackma}" -eq 1 ] && dep_ch "trackma"
Expand Down
6 changes: 6 additions & 0 deletions ani-cli.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Play the dubbed version. Without this flag, it'll always play the subbed version
.TP
\fB\--rofi\fR
Use rofi instead of fzf for the interactive menu
.TP
\fB\--skip\fR
Use ani-skip to skip the intro of the episode (mpv only)
.PP
.SH
ENVIRONMENT VARIABLES
Expand Down Expand Up @@ -89,6 +92,9 @@ Controls the directory ani-cli uses for storing history. A /ani-cli subfolder is
.TP
\fBANI_CLI_DEFAULT_SOURCE\fR
Controls the default source. Valid is history (equivalent to -c), everything else means search. Default is search.
.TP
\fBANI_CLI_SKIP_INTRO\fR
Controls if ani-skip is used to skip intros (works with mpv only). Can be 0 (disabled) or 1 (enabled). Default is 0.
.PP
.SH EPISODE SELECTION
.PP
Expand Down

0 comments on commit bb5bbb1

Please sign in to comment.