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