add -r flag to select previously watched anime and start at ep selection

This commit is contained in:
ksyasuda 2022-03-03 18:53:23 -08:00
parent aa39625956
commit aac3761e37
2 changed files with 25 additions and 4 deletions

14
ani-cli
View File

@ -744,13 +744,17 @@ parse_args() {
is_download=0
download_dir="."
half_ep=0
while getopts 'd:Hsvq:cf:t:T:CQ:D:Sp:' OPT; do
is_resume=0
while getopts 'd:Hsvq:cf:t:T:CQ:D:Sp:r' OPT; do
case "$OPT" in
d)
is_download=1
download_dir="$OPTARG"
lg "DOWNLOAD DIR: $download_dir"
;;
r)
is_resume=1
;;
H)
scrape=history
;;
@ -833,7 +837,13 @@ main() {
case $scrape in
query)
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.fi)"
stream "$@"
if ((is_resume == 1)); then
anime="$(run_stmt "SELECT anime_name FROM watch_history ORDER BY watch_date DESC LIMIT 1;")"
lg "Selecting last watched anime: $anime"
else
anime="$*"
fi
stream "$anime"
;;
history)
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.fi)"

View File

@ -170,12 +170,16 @@ set_theme() {
}
parse_args() {
while getopts 'vhqcdf:-:t:T:CQ:D:Sp' OPT; do
while getopts 'vhqcdf:t:T:CQ:D:Spr' OPT; do
case "$OPT" in
h)
help_text
exit 0
;;
r)
IS_RESUME=1
lg "Selecting previously watched anime"
;;
v)
VERBOSE=1
;;
@ -274,7 +278,11 @@ check_flags() {
lg "SELECTED PLAYER FN -> $PLAYER_FN"
fi
if ((IS_ROFI == 0 && IS_DOWNLOAD == 0)); then
if ((IS_RESUME == 1)); then
run -cr "$@"
else
run -c "$@"
fi
exit $?
elif ((IS_ROFI == 0 && IS_DOWNLOAD == 1)); then
prompt "Enter download directory"
@ -291,6 +299,9 @@ check_flags() {
elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 0)); then
run "-f$play_path" -t "$theme" "$@"
exit $?
elif ((IS_RESUME == 1)); then
run -r "$@"
exit $?
fi
}