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 is_download=0
download_dir="." download_dir="."
half_ep=0 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 case "$OPT" in
d) d)
is_download=1 is_download=1
download_dir="$OPTARG" download_dir="$OPTARG"
lg "DOWNLOAD DIR: $download_dir" lg "DOWNLOAD DIR: $download_dir"
;; ;;
r)
is_resume=1
;;
H) H)
scrape=history scrape=history
;; ;;
@ -833,7 +837,13 @@ main() {
case $scrape in case $scrape in
query) query)
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.fi)" 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) history)
BASE_URL="$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.fi)" 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() { 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 case "$OPT" in
h) h)
help_text help_text
exit 0 exit 0
;; ;;
r)
IS_RESUME=1
lg "Selecting previously watched anime"
;;
v) v)
VERBOSE=1 VERBOSE=1
;; ;;
@ -274,7 +278,11 @@ check_flags() {
lg "SELECTED PLAYER FN -> $PLAYER_FN" lg "SELECTED PLAYER FN -> $PLAYER_FN"
fi fi
if ((IS_ROFI == 0 && IS_DOWNLOAD == 0)); then if ((IS_ROFI == 0 && IS_DOWNLOAD == 0)); then
if ((IS_RESUME == 1)); then
run -cr "$@"
else
run -c "$@" run -c "$@"
fi
exit $? exit $?
elif ((IS_ROFI == 0 && IS_DOWNLOAD == 1)); then elif ((IS_ROFI == 0 && IS_DOWNLOAD == 1)); then
prompt "Enter download directory" prompt "Enter download directory"
@ -291,6 +299,9 @@ check_flags() {
elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 0)); then elif ((IS_ROFI == 1 && IS_PLAY_FROM_FILE == 1 && IS_CUSTOM_THEME == 0)); then
run "-f$play_path" -t "$theme" "$@" run "-f$play_path" -t "$theme" "$@"
exit $? exit $?
elif ((IS_RESUME == 1)); then
run -r "$@"
exit $?
fi fi
} }