#!/usr/bin/env bash BASE_URL="https://gogoplay4.com" CFG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/aniwrapper" HISTORY_DB="$CFG_DIR/history.sqlite3" ROFI_CFG="$CFG_DIR/themes/aniwrapper.rasi" ROFI_THEME="aniwrapper.rasi" THEMES="alter|aniwrapper|dracula|doomone|fancy|material|monokai|nord|nord2|onedark" ANIWRAPPER_ICON_PATH="$CFG_DIR/icons/icon-64.png" MAISAN_ICON_PATH="$CFG_DIR/icons/MYsan.png" DPI=96 IS_ROFI=1 VERBOSE=0 SILENT=0 FIRST_EP_NUMBER=1 PLAYER_FN="mpv" # display error message and exit die() { ((SILENT != 1)) && 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 } # 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" } # 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" } # 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 else menu_line_even "$1" "$2" menu_line_parity=0 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" } # check if input is valid and assings value/range to episodes variable check_input() { if [[ -z "$ep_choice_start" ]] && [[ -z "$ep_choice_end" ]]; then die "No episode(s) selected" fi [ "$ep_choice_start" -eq "$ep_choice_start" ] 2> /dev/null || die "Invalid number entered: $ep_choice_start" episodes=$ep_choice_start if [ -n "$ep_choice_end" ]; then [ "$ep_choice_end" -eq "$ep_choice_end" ] 2> /dev/null || die "Invalid number entered: $ep_choice_end" episodes=$(seq "$ep_choice_start" "$ep_choice_end") fi } # get the download page url get_dpage_link() { anime_id=$1 ep_no=$2 curl -s "$BASE_URL/videos/${anime_id}${ep_no}" | sed -nE 's_^[[:space:]]*