From e998c4f3253aa33ad5292a0312dfa2264e0e7585 Mon Sep 17 00:00:00 2001 From: konsthol Date: Mon, 30 Dec 2024 21:21:00 +0200 Subject: [PATCH] lots of changes after a lot of time --- grpoppro | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/grpoppro b/grpoppro index bd9e7eb..d4c3afc 100755 --- a/grpoppro +++ b/grpoppro @@ -30,15 +30,30 @@ UP_IN_REQ="Upgrade-Insecure-Requests: 1" ### Enf of curl constants ## End of definitions +# Display a message +function message { + if [[ "$INTERACTIVE" == "on" ]]; then + notify-send -t 2000 "$1" + else + echo -e "\n\t$1" + fi +} + # Standard curl request function curlRequest { - curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ + response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ -A "$USER_AGENT" \ -H "$ACCEPT" \ -H "$ACCEPT_LANGUAGE" \ -H "$CONNECTION" \ -H "$UP_IN_REQ" \ "$@" + )" + if [[ $? -ne 0 ]]; then + message "Error: Failed to execute curl request." + exit 1 + fi + echo "$response" } # Print usage information @@ -56,22 +71,14 @@ function getFzfForTermux { fi } -# Display a message -function message { - if [[ "$INTERACTIVE" == "on" ]]; then - notify-send -t 2000 "$1" - else - echo -e "\n\t$1" - fi -} - # Retrieve IMDb ID function getIMDBID { - imdbid="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ + response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ -A "$USER_AGENT" \ -H "$ACCEPT" \ - "https://www.imdb.com/find/?q=$title" | grep -io ' href=['"'"'"][^"'"'"']*['"'"'"]' | grep 'href="/title/'| head -n1 | sed -e 's/href="\/title\///' -e 's/\/?.*//' -e 's/^ //' + "https://www.imdb.com/find/?q=$title" )" + imdbid="$(echo "$response" | grep -io ' href=['"'"'"][^"'"'"']*['"'"'"]' | grep 'href="/title/'| head -n1 | sed -e 's/href="\/title\///' -e 's/\/?.*//' -e 's/^ //')" # imdbid="$(curl -s "http://imdb.konsthol.eu/find?q=$title" | grep -io ' href=['"'"'"][^"'"'"']*['"'"'"]' | grep title | head -n1 | sed -e 's/^ //' -e 's/href="\/title\///' -e 's/"//')" if ! [[ "$imdbid" == *"tt"* ]]; then message "Film or show not found in imdb"