diff --git a/ani-cli b/ani-cli index 419ef40..2e0357b 100755 --- a/ani-cli +++ b/ani-cli @@ -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)" diff --git a/aniwrapper b/aniwrapper index 7d20412..54718a6 100755 --- a/aniwrapper +++ b/aniwrapper @@ -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 - run -c "$@" + 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 }