From f7cd4ed7a28dd0c36b571bdd3791d73a2bdd2705 Mon Sep 17 00:00:00 2001 From: konsthol Date: Mon, 30 Dec 2024 20:44:36 +0200 Subject: [PATCH] Improving the fix --- grpoppro | 61 +++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/grpoppro b/grpoppro index d9dc63e..4397adf 100755 --- a/grpoppro +++ b/grpoppro @@ -21,10 +21,26 @@ MPV_OPTS='--vo=gpu \ --no-ytdl \ --http-header-fields="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0" \ --fs' +### Curl constants USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0" -ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" +ACCEPT="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" +ACCEPT_LANGUAGE="Accept-Language: en-US,en;q=0.5" +CONNECTION="Connection: keep-alive" +UP_IN_REQ="Upgrade-Insecure-Requests: 1" +### Enf of curl constants ## End of definitions +# Standard curl request +function curlRequest { + 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" \ + "$@" +} + # Print usage information function usage { echo -e "\n\tUsage:\n\n\t$(basename "$0") \"name of film or show\" [season] [episode(ex 01 02 .. 10 11)]" @@ -53,7 +69,7 @@ function message { function getIMDBID { imdbid="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ -A "$USER_AGENT" \ - -H "Accept: $ACCEPT" \ + -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/^ //' )" # 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/"//')" @@ -73,14 +89,7 @@ function basics { # Retrieve internal ID function getInternalID { - response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ - -A "$USER_AGENT" \ - -H "Accept: $ACCEPT" \ - -H "Accept-Language: en-US,en;q=0.5" \ - -H "Connection: keep-alive" \ - -H "Upgrade-Insecure-Requests: 1" \ - "$simpleurl" - )" + response="$(curlRequest "$simpleurl")" if echo "$response" | grep -q "id='el-content'>"; then message "No file found" exit 0 @@ -92,16 +101,16 @@ function getInternalID { function getMovieStreamUrl { PHPSESSID="$(grep 'PHPSESSID' "$GRPOPPRO_COOKIE_FILE" | awk '{print $NF}')" streamurl="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" "$apiurl/engine/ajax/controller.php" --compressed -X POST \ - -H "$USER_AGENT" \ + -A "$USER_AGENT" \ -H 'Accept: application/json, text/javascript, */*; q=0.01' \ - -H 'Accept-Language: en-US,en;q=0.5' \ + -H "$ACCEPT_LANGUAGE" \ -H 'Accept-Encoding: gzip, deflate, br, zstd' \ -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ -H 'X-Requested-With: XMLHttpRequest' \ -H "Origin: $apiurl" \ -H 'DNT: 1' \ -H 'Sec-GPC: 1' \ - -H 'Connection: keep-alive' \ + -H "$CONNECTION" \ -H "Referer: $simpleurl" \ -H "Cookie: PHPSESSID=$PHPSESSID" \ -H 'Sec-Fetch-Dest: empty' \ @@ -159,10 +168,10 @@ function menuSearch { getInternalID "$simpleurl" response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ -A "$USER_AGENT" \ - -H "Accept: $ACCEPT" \ - -H "Accept-Language: en-US,en;q=0.5" \ - -H "Connection: keep-alive" \ - -H "Upgrade-Insecure-Requests: 1" \ + -H "$ACCEPT" \ + -H "$ACCEPT_LANGUAGE" \ + -H "$CONNECTION" \ + -H "$UP_IN_REQ" \ "$apiurl/uploads/playlists/$internalid.txt" )" echo "$response" > "$GRPOPPRO_PLAYLIST_FILE" @@ -228,14 +237,7 @@ function resumeSeries { getIMDBID "$title" simpleurl="$apiurl/embed/$imdbid/" getInternalID "$simpleurl" - response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ - -A "$USER_AGENT" \ - -H "Accept: $ACCEPT" \ - -H "Accept-Language: en-US,en;q=0.5" \ - -H "Connection: keep-alive" \ - -H "Upgrade-Insecure-Requests: 1" \ - "$apiurl/uploads/playlists/$internalid.txt" - )" + response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")" echo "$response" > "$GRPOPPRO_PLAYLIST_FILE" title="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | head -n1 | awk -F/ '{print $(NF-1)}')" title="${title//_/ }" @@ -318,13 +320,8 @@ if [[ "$#" -eq 3 ]]; then getInternalID "$simpleurl" season="$2" episode="$3" - streamurl="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \ - -A "$USER_AGENT" \ - -H "Accept: $ACCEPT" \ - -H "Accept-Language: en-US,en;q=0.5" \ - -H "Connection: keep-alive" \ - -H "Upgrade-Insecure-Requests: 1" \ - "$apiurl/uploads/playlists/$internalid.txt" | grep "mp4" | grep "${season}x${episode}" | head -n1 | awk -F\" '{print $8}')" + response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")" + streamurl="$(echo "$response" | grep "mp4" | grep "${season}x${episode}" | head -n1 | awk -F\" '{print $8}')" play exit 0 fi