only get base_url if scrape is stream or history

This commit is contained in:
ksyasuda 2022-01-31 02:42:35 -08:00
parent b07948cee2
commit ddb8d01ff2

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
HISTORY_DB="$CFG_DIR/history.sqlite3"
PLAYER_CMD="mpv"
@ -847,9 +846,11 @@ parse_args() {
main() {
case $scrape in
query)
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
stream
;;
history)
BASE_URL=$(curl -s -L -o /dev/null -w "%{url_effective}\n" https://gogoanime.cm)
stmt="SELECT DISTINCT anime_name FROM watch_history ORDER BY watch_date DESC"
search_results=$(printf "%s\n" "$stmt" | sqlite3 -noheader "$HISTORY_DB")
[ -z "$search_results" ] && die "History is empty"