Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added flag for mpv as flatpak #1411

Merged
merged 8 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions ani-cli
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ help_info() {
Download the video instead of playing it
-D, --delete
Delete history
-f, --flatpak-mpv
Use mpv (flatpak) to play the video
-l, --logview
Show logs
-s, --syncplay
Expand Down Expand Up @@ -124,6 +122,12 @@ where_iina() {
dep_ch iina # exit with formating
}

where_mpv() {
command -v "$ANI_CLI_PLAYER" >/dev/null && printf "%s" "$ANI_CLI_PLAYER" && return 0
command -v "flatpak" >/dev/null && flatpak info io.mpv.Mpv >/dev/null 2>&1 && printf "%s" "flatpak_mpv" && return 0
dep_ch mpv # exit with formating
}

# SCRAPING

# extract the video links from response of embed urls, extract mp4 links form m3u8 lists
Expand Down Expand Up @@ -337,10 +341,12 @@ quality="${ANI_CLI_QUALITY:-best}"
case "$(uname -a)" in
*Darwin*) player_function="$(where_iina)" ;; # mac OS
*ndroid*) player_function="${ANI_CLI_PLAYER:-android_mpv}" ;; # Android OS (termux)
*neptune*) player_function="${ANI_CLI_PLAYER:-flatpak_mpv}" ;; # steamdeck OS
*MINGW* | *WSL2*) player_function="${ANI_CLI_PLAYER:-mpv.exe}" ;; # Windows OS
*ish*) player_function="${ANI_CLI_PLAYER:-iSH}" ;; # iOS (iSH)
*) player_function="${ANI_CLI_PLAYER:-mpv}" ;; # Linux OS
*)
player_function="${ANI_CLI_PLAYER:-$(where_mpv)}" # Linux OS
[ $? -eq 0 ] || exit $?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is actually not necessary, since dep_ch will already exit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it, it doesn't.

;;
esac

no_detach="${ANI_CLI_NO_DETACH:-0}"
Expand All @@ -366,9 +372,6 @@ while [ $# -gt 0 ]; do
*) player_function="vlc" ;;
esac
;;
-f | --flatpak-mpv)
player_function="flatpak_mpv"
;;
-s | --syncplay)
case "$(uname -s)" in
Darwin*) player_function="/Applications/Syncplay.app/Contents/MacOS/syncplay" ;;
Expand Down Expand Up @@ -436,13 +439,10 @@ if [ -z "$ANI_CLI_NON_INTERACTIVE" ]; then dep_ch fzf || true; fi
case "$player_function" in
debug) ;;
download) dep_ch "ffmpeg" "aria2c" ;;
flatpak*)
dep_ch "flatpak"
flatpak info io.mpv.Mpv >/dev/null 2>&1 || die "Program \"mpv (flatpak)\" not found. Please install it."
;;
android*) printf "\33[2K\rChecking of players on Android is disabled\n" ;;
*iSH*) printf "\33[2K\rChecking of players on iOS is disabled\n" ;;
*iina*) true ;; # handled out of band in where_iina
*mpv*) true ;; # handled out of band in where_mpv
*) dep_ch "$player_function" ;;
esac

Expand Down
3 changes: 0 additions & 3 deletions ani-cli.1
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ Continue watching anime from history.
\fB\-d | --download\fR
Download episode.
.TP
\fB\-f | --flatpak-mpv\fR
Wathc anime via mpv packaged as flatpak.
.TP
\fB\-D | --delete\fR
Delete history.
.TP
Expand Down
Loading