diff --git a/ani-cli b/ani-cli
index ccc7750..50e9eed 100755
--- a/ani-cli
+++ b/ani-cli
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
AGENT="Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0"
-BASE_URL="https://goload.pro"
+BASE_URL="https://animixplay.to"
CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper"
-URLFILE="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper/ani-url"
+JOBFILE="${XDG_CACHE_HOME:-$HOME/.cache}/aniwrapper-jobs"
+TMPDIR="${XDG_CACHE_HOME:-$HOME/.cache}/aniwrapper-temp"
HISTORY_DB="$CFG_DIR/history.sqlite3"
ROFI_CFG="$CFG_DIR/themes/aniwrapper.rasi"
ROFI_THEME="aniwrapper.rasi"
@@ -16,58 +17,44 @@ VERBOSE=0
SILENT=0
FIRST_EP_NUMBER=1
PLAYER_FN="mpv"
+PID=0
# display error message and exit
die() {
- ((SILENT != 1)) && printf "\033[1;31m%s\033[0m\n" "$*" >&2
+ ((!SILENT)) && printf "\033[1;31m%s\033[0m\n" "$*" >&2
exit 1
}
-# display an error message to stderr (in red)
-err() {
- ((SILENT != 1)) && printf "\033[1;31m%s\033[0m\n" "$*" >&2
-}
-
# display a log message if verbose mode is enabled
lg() {
- ((VERBOSE == 1)) && printf "\033[1;35m%s\033[0m\n" "$*" >&2
+ ((VERBOSE)) && printf "\033[1;35m%s\033[0m\n" "$*" >&2
}
# display an informational message (first argument in green, second in magenta)
inf() {
- printf "\033[1;35m%s \033[1;35m%s\033[0m\n" "$1" "$2"
+ printf "\33[2K\r\033[1;35m%s \033[1;35m%s\033[0m\n" "$1" "$2"
}
-# prompts the user with message in $1-2 ($1 in blue, $2 in magenta) and saves the input to the variables in $REPLY and $REPLY2
-prompt() {
- printf "\033[1;35m%s\033[1;35m%s\033[1;34m\033[0m: " "$1" "$2"
+progress() {
+ ((!SILENT)) && printf "\33[2K\r\033[1;34m%s\033[0m\n" "$1" >&2
}
-# displays an even (cyan) line of a menu line with $2 as an indicator in [] and $1 as the option
-menu_line_even() {
- printf "\033[1;36m(\033[1;36m%s\033[1;36m) \033[1;36m%s\033[0m\n" "$2" "$1"
-}
-
-# displays an odd (yellow) line of a menu line with $2 as an indicator in [] and $1 as the option
-menu_line_odd() {
- printf "\033[1;33m(\033[1;33m%s\033[1;33m) \033[1;33m%s\033[0m\n" "$2" "$1"
-}
-
-# display alternating menu lines (even and odd)
-menu_line_alternate() {
- menu_line_parity=${menu_line_parity:-0}
- if [ "$menu_line_parity" -eq 0 ]; then
- menu_line_odd "$1" "$2"
- menu_line_parity=1
+# sends a notification to notify-send if available, else prints to stdout
+notification() {
+ ((SILENT)) && return 0
+ msg="$*"
+ if command -v "notify-send" > /dev/null; then
+ notify-send -i "$ANIWRAPPER_ICON_PATH" "$msg"
else
- menu_line_even "$1" "$2"
- menu_line_parity=0
+ inf "$msg"
fi
}
-# displays a warning (red) line of a menu line with $2 as an indicator in [] and $1 as the option
-menu_line_strong() {
- printf "\033[1;34m[\033[1;33m%s\033[1;34m] \033[1;33m%s\033[0m\n" "$2" "$1"
+# generates a pre-styled span tag with the given msg
+generate_span() {
+ msg="$*"
+ span="$msg"
+ printf "%s\n" "$span"
}
# check if input is valid and assings value/range to episodes variable
@@ -83,189 +70,206 @@ check_input() {
fi
}
-# get the download page url
-get_dpage_link() {
- anime_id=$1
- ep_no=$2
- curl -A "$AGENT" -s "$BASE_URL/videos/${anime_id}${ep_no}" | sed -nE 's_^[[:space:]]*