diff --git a/grpoppro b/grpoppro index 9fb31a9..a25c691 100755 --- a/grpoppro +++ b/grpoppro @@ -2,15 +2,14 @@ ## Definitions GRPOPPRO_DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/grpoppro" +GRPOPPRO_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/grpoppro" +GRPOPPRO_CONFIG_FILE="$GRPOPPRO_CONFIG_DIR/grpopprorc" GRPOPPRO_DATA_FILE="$GRPOPPRO_DATA_DIR/lastPlayedSeries" GRPOPPRO_PLAYLIST_FILE="$GRPOPPRO_DATA_DIR/lastPlaylistPlayed" GRPOPPRO_COOKIE_FILE="$GRPOPPRO_DATA_DIR/cookies.txt" GRPOPPRO_HISTORY_FILE="$GRPOPPRO_DATA_DIR/history" GRPOPPRO_INTERACTIVE="on" GRPOPPRO_DEBUG="on" -menu="fuzzel -d -p " -#menu="fzf -i --prompt=" -apiurl="https://coverapi.store" ### Curl constants USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0" ACCEPT="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" @@ -18,7 +17,6 @@ ACCEPT_LANGUAGE="Accept-Language: en-US,en;q=0.5" CONNECTION="Connection: keep-alive" UP_IN_REQ="Upgrade-Insecure-Requests: 1" ### End of curl constants -player="mpv" MPV_OPTS='--vo=gpu \ --gpu-api=opengl \ --opengl-es=yes \ @@ -567,6 +565,40 @@ function getMovie { ### Program starts here ### +if [[ -f "$GRPOPPRO_CONFIG_FILE" ]]; then + while IFS='=' read -r key value; do + # Ignore lines starting with # + if [[ "$key" =~ ^#.* ]]; then + continue + fi + # Check if value starts and ends with quotes + if [[ $value =~ ^\".*\"$ ]]; then + # Remove surrounding quotes, but preserve internal spaces + value="${value%\"}" # Remove trailing quote + value="${value#\"}" # Remove leading quote + else + # Wont appear for empty config file + # But will appear for empty lines + echo "Invalid value found" + exit 1 + fi + export "$key=$value" + done < "$GRPOPPRO_CONFIG_FILE" +else + echo "Configuration file not found!" + echo "Creating one at $GRPOPPRO_CONFIG_FILE" + mkdir -p "$GRPOPPRO_CONFIG_DIR" + touch "$GRPOPPRO_CONFIG_FILE" + exit 1 +fi + +# Set default values if not set in config +: "${GRPOPPRO_INTERACTIVE:=on}" +: "${GRPOPPRO_DEBUG:=on}" +: "${apiurl:=https://coverapi.store}" +: "${player:=mpv}" +: "${menu:=fuzzel -d -p }" + # Ensure curl-impersonate is installed if ! command -v curl-impersonate-ff >/dev/null 2>&1; then message "You should get curl-impersonate to make it seem less obvious you use curl"