mirror of
https://github.com/ksyasuda/aniwrapper.git
synced 2024-11-22 03:19:53 -08:00
Compare commits
No commits in common. "ba6c30202222708a92e498a9f5b69915e84e2277" and "692301d8933afb4f649593d8ff1a18e4a7e257f0" have entirely different histories.
ba6c302022
...
692301d893
165
ani-cli
165
ani-cli
@ -754,28 +754,12 @@ episode_selection() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
continue_watching() {
|
|
||||||
if ((IS_ROFI == 1)); then
|
|
||||||
msg="$(printf '%s\n%s' "$(generate_span "Anime: $anime_id")" "$(generate_span "Next episode: $((episode + 1))")")"
|
|
||||||
choice=$(rofi -dmenu -dpi "$DPI" -config "$ROFI_CFG" \
|
|
||||||
-theme-str 'listview {columns: 1;} window {width: 25%;}' \
|
|
||||||
-i -l 2 -no-custom -sep '|' -a 0 -mesg "$msg" \
|
|
||||||
-p "Continue watching?" -window-title 'aniwrapper' <<< "Yes|No")
|
|
||||||
else
|
|
||||||
inf "Continue watching $selection_id?"
|
|
||||||
prompt "Next episode -> $((episode + 1)) [Y/n]"
|
|
||||||
read -r choice
|
|
||||||
[ -z "$choice" ] && choice="y"
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ "$choice" =~ ^(y|Y|Yes)$ ]] && return 0 || return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
open_episode() {
|
open_episode() {
|
||||||
anime_id="$1"
|
anime_id="$1"
|
||||||
episode="$2"
|
episode="$2"
|
||||||
ddir="$3"
|
ddir="$3"
|
||||||
|
|
||||||
|
# Don't update watch history if downloading episode
|
||||||
insert_history "watch" "$anime_id" "$episode"
|
insert_history "watch" "$anime_id" "$episode"
|
||||||
|
|
||||||
lg "Getting data for episode $episode"
|
lg "Getting data for episode $episode"
|
||||||
@ -808,15 +792,6 @@ open_episode() {
|
|||||||
else
|
else
|
||||||
((SILENT != 1)) && inf "Playing $anime_id - Episode $episode"
|
((SILENT != 1)) && inf "Playing $anime_id - Episode $episode"
|
||||||
fi
|
fi
|
||||||
if ((is_autoplay == 1)); then
|
|
||||||
lg "Waiting for video to finish playing..."
|
|
||||||
wait "$PID"
|
|
||||||
if ((episode + 1 <= LAST_EP_NUMBER)) && continue_watching; then
|
|
||||||
open_episode "$anime_id" "$((episode + 1))" "$ddir"
|
|
||||||
else
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
lg "Downloading episode $episode ..."
|
lg "Downloading episode $episode ..."
|
||||||
dl_dir="${ddir// /}/$anime_id"
|
dl_dir="${ddir// /}/$anime_id"
|
||||||
@ -876,12 +851,8 @@ parse_args() {
|
|||||||
quality=best
|
quality=best
|
||||||
is_download=0
|
is_download=0
|
||||||
is_resume=0
|
is_resume=0
|
||||||
is_autoplay=0
|
while getopts 'd:Hsvq:cf:t:T:CQ:D:Sp:r' OPT; do
|
||||||
while getopts 'ad:Hsvq:cf:t:T:CQ:D:Sp:r' OPT; do
|
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
|
||||||
is_autoplay=1
|
|
||||||
;;
|
|
||||||
d)
|
d)
|
||||||
is_download=1
|
is_download=1
|
||||||
download_dir="$OPTARG"
|
download_dir="$OPTARG"
|
||||||
@ -965,71 +936,6 @@ parse_args() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
show_menu() {
|
|
||||||
if ((SILENT != 1)); then
|
|
||||||
episode=${ep_choice_end:-$ep_choice_start}
|
|
||||||
choice=''
|
|
||||||
while :; do
|
|
||||||
inf "Currently playing $selection_id episode" "${episode// /}/$LAST_EP_NUMBER"
|
|
||||||
((episode != LAST_EP_NUMBER)) && menu_line_alternate "next episode" "n"
|
|
||||||
((episode != FIRST_EP_NUMBER)) && menu_line_alternate "previous episode" "p"
|
|
||||||
((FIRST_EP_NUMBER != LAST_EP_NUMBER)) && menu_line_alternate "select episode" "s"
|
|
||||||
menu_line_alternate "replay current episode" "r"
|
|
||||||
menu_line_alternate "search for another anime" "a"
|
|
||||||
menu_line_alternate "download current episode" "d"
|
|
||||||
menu_line_alternate "download current episode (with quality selection)" "D"
|
|
||||||
menu_line_alternate "select video quality (current: $quality)" "Q"
|
|
||||||
menu_line_strong "exit" "q"
|
|
||||||
prompt "Enter choice"
|
|
||||||
read -r choice
|
|
||||||
case $choice in
|
|
||||||
n)
|
|
||||||
episode=$((episode + 1))
|
|
||||||
;;
|
|
||||||
p)
|
|
||||||
episode=$((episode - 1))
|
|
||||||
;;
|
|
||||||
|
|
||||||
s)
|
|
||||||
episode_selection
|
|
||||||
episode=$ep_choice_start
|
|
||||||
;;
|
|
||||||
|
|
||||||
r)
|
|
||||||
episode=$((episode))
|
|
||||||
;;
|
|
||||||
a)
|
|
||||||
stream
|
|
||||||
episode=$ep_choice_start
|
|
||||||
lg "NEW EPISODE: $selection_id - $episode"
|
|
||||||
;;
|
|
||||||
Q)
|
|
||||||
set_video_quality
|
|
||||||
episode=$((episode))
|
|
||||||
;;
|
|
||||||
|
|
||||||
d)
|
|
||||||
get_dl_dir
|
|
||||||
is_download=1
|
|
||||||
;;
|
|
||||||
D)
|
|
||||||
get_dl_dir
|
|
||||||
set_video_quality
|
|
||||||
is_download=1
|
|
||||||
;;
|
|
||||||
q)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
die "invalid choice"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
open_episode "$selection_id" "$episode" "$download_dir"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
case $scrape in
|
case $scrape in
|
||||||
query)
|
query)
|
||||||
@ -1106,11 +1012,72 @@ main() {
|
|||||||
open_episode "$selection_id" "$ep" "$download_dir"
|
open_episode "$selection_id" "$ep" "$download_dir"
|
||||||
done
|
done
|
||||||
|
|
||||||
if ((is_download == 1)); then
|
if [[ "$is_download" -eq 1 ]]; then
|
||||||
lg "Finished downloading episodes: $episodes for $selection_id... exiting"
|
lg "Finished downloading episodes: $episodes for $selection_id... exiting"
|
||||||
exit 0
|
exit 0
|
||||||
elif ((is_autoplay == 0)); then
|
fi
|
||||||
show_menu
|
|
||||||
|
if ((SILENT != 1)); then
|
||||||
|
episode=${ep_choice_end:-$ep_choice_start}
|
||||||
|
choice=''
|
||||||
|
while :; do
|
||||||
|
inf "Currently playing $selection_id episode" "${episode// /}/$LAST_EP_NUMBER"
|
||||||
|
((episode != LAST_EP_NUMBER)) && menu_line_alternate "next episode" "n"
|
||||||
|
((episode != FIRST_EP_NUMBER)) && menu_line_alternate "previous episode" "p"
|
||||||
|
((FIRST_EP_NUMBER != LAST_EP_NUMBER)) && menu_line_alternate "select episode" "s"
|
||||||
|
menu_line_alternate "replay current episode" "r"
|
||||||
|
menu_line_alternate "search for another anime" "a"
|
||||||
|
menu_line_alternate "download current episode" "d"
|
||||||
|
menu_line_alternate "download current episode (with quality selection)" "D"
|
||||||
|
menu_line_alternate "select video quality (current: $quality)" "Q"
|
||||||
|
menu_line_strong "exit" "q"
|
||||||
|
prompt "Enter choice"
|
||||||
|
read -r choice
|
||||||
|
case $choice in
|
||||||
|
n)
|
||||||
|
episode=$((episode + 1))
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
episode=$((episode - 1))
|
||||||
|
;;
|
||||||
|
|
||||||
|
s)
|
||||||
|
episode_selection
|
||||||
|
episode=$ep_choice_start
|
||||||
|
;;
|
||||||
|
|
||||||
|
r)
|
||||||
|
episode=$((episode))
|
||||||
|
;;
|
||||||
|
a)
|
||||||
|
stream
|
||||||
|
episode=$ep_choice_start
|
||||||
|
lg "NEW EPISODE: $selection_id - $episode"
|
||||||
|
;;
|
||||||
|
Q)
|
||||||
|
set_video_quality
|
||||||
|
episode=$((episode))
|
||||||
|
;;
|
||||||
|
|
||||||
|
d)
|
||||||
|
get_dl_dir
|
||||||
|
is_download=1
|
||||||
|
;;
|
||||||
|
D)
|
||||||
|
get_dl_dir
|
||||||
|
set_video_quality
|
||||||
|
is_download=1
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
die "invalid choice"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
open_episode "$selection_id" "$episode" "$download_dir"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
aniwrapper
29
aniwrapper
@ -16,7 +16,6 @@ SUPPORTED_PLAYERS="mpv|vlc"
|
|||||||
QUALITY=best
|
QUALITY=best
|
||||||
PLAYER_FN=mpv
|
PLAYER_FN=mpv
|
||||||
DPI=96
|
DPI=96
|
||||||
IS_AUTOPLAY=0
|
|
||||||
GET_QUALITY=0
|
GET_QUALITY=0
|
||||||
IS_CUSTOM_THEME=0
|
IS_CUSTOM_THEME=0
|
||||||
IS_DOWNLOAD=0
|
IS_DOWNLOAD=0
|
||||||
@ -36,13 +35,12 @@ help_text() {
|
|||||||
printf "%s\n" "$line"
|
printf "%s\n" "$line"
|
||||||
done <<< "
|
done <<< "
|
||||||
Usage:
|
Usage:
|
||||||
aniwrapper [-adhpqSv] [-t <theme> | -T <config_path>] [<query>]
|
aniwrapper [-dhpqSv] [-t <theme> | -T <config_path>] [<query>]
|
||||||
aniwrapper -f <directory_path> [-t <theme> | -T <config_path>] [-pSv] [<query>]\
|
aniwrapper -f <directory_path> [-t <theme> | -T <config_path>] [-pSv] [<query>]\
|
||||||
aniwrapper -c [-dhpqSv] [<query>]
|
aniwrapper -c [-dhpqSv] [<query>]
|
||||||
aniwrapper -Q <query>
|
aniwrapper -Q <query>
|
||||||
aniwrapper -C
|
aniwrapper -C
|
||||||
Options:
|
Options:
|
||||||
-a enable autoplay
|
|
||||||
-c enable command-line mode (rofi disabled)
|
-c enable command-line mode (rofi disabled)
|
||||||
-C connect to history database
|
-C connect to history database
|
||||||
-d download episode in command-line mode
|
-d download episode in command-line mode
|
||||||
@ -89,26 +87,23 @@ run() {
|
|||||||
if ((IS_PLAY_FROM_FILE == 0 && IS_SYNC == 0 && GET_QUALITY == 1)); then
|
if ((IS_PLAY_FROM_FILE == 0 && IS_SYNC == 0 && GET_QUALITY == 1)); then
|
||||||
get_quality
|
get_quality
|
||||||
fi
|
fi
|
||||||
if ((IS_AUTOPLAY)); then
|
|
||||||
CMD="$CMD -a"
|
|
||||||
fi
|
|
||||||
if ((SILENT == 1)); then
|
if ((SILENT == 1)); then
|
||||||
if ((IS_CUSTOM_THEME == 0)); then
|
if ((IS_CUSTOM_THEME == 0)); then
|
||||||
$CMD -D"$DPI" -Sq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
|
"$CMD" -D"$DPI" -Sq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
|
||||||
else
|
else
|
||||||
$CMD -D"$DPI" -Sq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
|
"$CMD" -D"$DPI" -Sq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
|
||||||
fi
|
fi
|
||||||
elif ((VERBOSE == 1)); then
|
elif ((VERBOSE == 1)); then
|
||||||
if ((IS_CUSTOM_THEME == 0)); then
|
if ((IS_CUSTOM_THEME == 0)); then
|
||||||
$CMD -D"$DPI" -vq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
|
"$CMD" -D"$DPI" -vq "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
|
||||||
else
|
else
|
||||||
$CMD -D"$DPI" -vq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
|
"$CMD" -D"$DPI" -vq "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if ((IS_CUSTOM_THEME == 0)); then
|
if ((IS_CUSTOM_THEME == 0)); then
|
||||||
$CMD -D"$DPI" -q "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
|
"$CMD" -D"$DPI" -q "$QUALITY" -t "$theme" -p "$PLAYER_FN" "$@"
|
||||||
else
|
else
|
||||||
$CMD -D"$DPI" -q "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
|
"$CMD" -D"$DPI" -q "$QUALITY" -T "$CFG_FILE" -p "$PLAYER_FN" "$@"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -173,11 +168,8 @@ set_theme() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
while getopts 'acCdD:f:hpqQ:rSt:T:v' OPT; do
|
while getopts 'cCdD:f:hpqQ:rSt:T:v' OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
a)
|
|
||||||
IS_AUTOPLAY=1
|
|
||||||
;;
|
|
||||||
c)
|
c)
|
||||||
IS_ROFI=0
|
IS_ROFI=0
|
||||||
lg "Command-line (ani-cli) mode set"
|
lg "Command-line (ani-cli) mode set"
|
||||||
@ -275,9 +267,6 @@ check_flags() {
|
|||||||
if ((VERBOSE == 1 && SILENT == 1)); then
|
if ((VERBOSE == 1 && SILENT == 1)); then
|
||||||
die "verbose and silent options cannot be used together"
|
die "verbose and silent options cannot be used together"
|
||||||
fi
|
fi
|
||||||
if ((IS_DOWNLOAD == 1 && IS_AUTOPLAY == 1)); then
|
|
||||||
die "autoplay and download options cannot be used together"
|
|
||||||
fi
|
|
||||||
if ((IS_DOWNLOAD == 0 && IS_ALTERNATE_PLAYER == 1)); then
|
if ((IS_DOWNLOAD == 0 && IS_ALTERNATE_PLAYER == 1)); then
|
||||||
get_player
|
get_player
|
||||||
lg "SELECTED PLAYER FN -> $PLAYER_FN"
|
lg "SELECTED PLAYER FN -> $PLAYER_FN"
|
||||||
@ -358,7 +347,7 @@ main() {
|
|||||||
span=$(printf '%s\n%s\n' "$(generate_span "Provide a path to a valid directory, or choose from the list below")" "$(generate_span "The program will begin searching for media files from the supplied directory")")
|
span=$(printf '%s\n%s\n' "$(generate_span "Provide a path to a valid directory, or choose from the list below")" "$(generate_span "The program will begin searching for media files from the supplied directory")")
|
||||||
play_dir=$(
|
play_dir=$(
|
||||||
rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
|
rofi -dpi "$DPI" -dmenu -config "$CFG_FILE" \
|
||||||
-i -l 12 -mesg "$span" -p "Enter path to starting directory:" \
|
-l 12 -mesg "$span" -p "Enter path to starting directory:" \
|
||||||
-async-pre-read 24 -matching 'fuzzy' -window-title 'aniwrapper' \
|
-async-pre-read 24 -matching 'fuzzy' -window-title 'aniwrapper' \
|
||||||
-sort -sorting-method fzf \
|
-sort -sorting-method fzf \
|
||||||
< <(sqlite3 -noheader -list "$CFG_DIR/history.sqlite3" <<< "SELECT directory FROM file_history WHERE filename = 'DIRECTORY' ORDER BY WATCH_DATE DESC;")
|
< <(sqlite3 -noheader -list "$CFG_DIR/history.sqlite3" <<< "SELECT directory FROM file_history WHERE filename = 'DIRECTORY' ORDER BY WATCH_DATE DESC;")
|
||||||
|
@ -1,19 +1,5 @@
|
|||||||
.\" Automatically generated by Pandoc 2.17.1.1
|
.\" Automatically generated by Pandoc 2.14.2
|
||||||
.\"
|
.\"
|
||||||
.\" Define V font for inline verbatim, using C font in formats
|
|
||||||
.\" that render this, and otherwise B font.
|
|
||||||
.ie "\f[CB]x\f[]"x" \{\
|
|
||||||
. ftr V B
|
|
||||||
. ftr VI BI
|
|
||||||
. ftr VB B
|
|
||||||
. ftr VBI BI
|
|
||||||
.\}
|
|
||||||
.el \{\
|
|
||||||
. ftr V CR
|
|
||||||
. ftr VI CI
|
|
||||||
. ftr VB CB
|
|
||||||
. ftr VBI CBI
|
|
||||||
.\}
|
|
||||||
.TH "ANIWRAPPER" "1" "February 4, 2022" "aniwrapper 1.0.0" "Man Page"
|
.TH "ANIWRAPPER" "1" "February 4, 2022" "aniwrapper 1.0.0" "Man Page"
|
||||||
.hy
|
.hy
|
||||||
.SH NAME
|
.SH NAME
|
||||||
@ -22,7 +8,7 @@ aniwrapper - A rofi wrapper around ani-cli: a command-line tool to
|
|||||||
stream, download, and play anime
|
stream, download, and play anime
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.PP
|
.PP
|
||||||
\f[B]aniwrapper\f[R] [-adhpqrSv] [-t \f[I]theme\f[R] | -T
|
\f[B]aniwrapper\f[R] [-dhpqrSv] [-t \f[I]theme\f[R] | -T
|
||||||
\f[I]config_path\f[R]] [\f[I]query\f[R]]
|
\f[I]config_path\f[R]] [\f[I]query\f[R]]
|
||||||
.PD 0
|
.PD 0
|
||||||
.P
|
.P
|
||||||
@ -57,9 +43,6 @@ aniwrapper.rasi theme
|
|||||||
.IP \[bu] 2
|
.IP \[bu] 2
|
||||||
best quality
|
best quality
|
||||||
.TP
|
.TP
|
||||||
\f[B]-a\f[R]
|
|
||||||
Enable autoplay in streaming mode
|
|
||||||
.TP
|
|
||||||
\f[B]-c\f[R]
|
\f[B]-c\f[R]
|
||||||
Enable command-line mode (disable \f[B]rofi\f[R])
|
Enable command-line mode (disable \f[B]rofi\f[R])
|
||||||
.TP
|
.TP
|
||||||
|
@ -12,7 +12,7 @@ aniwrapper - A rofi wrapper around ani-cli: a command-line tool to stream, downl
|
|||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
**aniwrapper** [-adhpqrSv] [-t _theme_ | -T _config_path_] [_query_]\
|
**aniwrapper** [-dhpqrSv] [-t _theme_ | -T _config_path_] [_query_]\
|
||||||
**aniwrapper** -f _directory_path_ [-t _theme_ | -T _config_path_] [-pSv] [_query_]\
|
**aniwrapper** -f _directory_path_ [-t _theme_ | -T _config_path_] [-pSv] [_query_]\
|
||||||
**aniwrapper** -c [-dhpqrSv] [_query_]\
|
**aniwrapper** -c [-dhpqrSv] [_query_]\
|
||||||
**aniwrapper** -Q _query_\
|
**aniwrapper** -Q _query_\
|
||||||
@ -32,9 +32,6 @@ Defaults:
|
|||||||
- aniwrapper.rasi theme
|
- aniwrapper.rasi theme
|
||||||
- best quality
|
- best quality
|
||||||
|
|
||||||
**-a**
|
|
||||||
: Enable autoplay in streaming mode
|
|
||||||
|
|
||||||
**-c**
|
**-c**
|
||||||
: Enable command-line mode (disable **rofi**)
|
: Enable command-line mode (disable **rofi**)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user