From 2b16d8298477a68a2a939006208b5709f7615864 Mon Sep 17 00:00:00 2001 From: konsthol Date: Sat, 4 Jan 2025 20:03:53 +0200 Subject: [PATCH] We know the game and we're gonna play it --- grpoppro | 91 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/grpoppro b/grpoppro index 0d167d9..8249faf 100755 --- a/grpoppro +++ b/grpoppro @@ -445,6 +445,43 @@ function getHistory { } +function getSeries { + # Two requests to the api + basics "$1" + getInternalID "$simpleurl" + season="$2" + episode="$3" + response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")" + streamurl="$(echo "$response" \ + | jq '.[]' \ + | grep "mp4" \ + | grep "${season}x${episode}" \ + | head -n1 \ + | awk -F\" '{print $4}' + )" + title="${title//%20/ }" + capitalized_title="$(echo "$title" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')" + message "Loading $capitalized_title at season $season on episode $episode" + play + exit 0 +} + +function getMovie { + # Two requests to the api + if [[ "$1" == *"tt"* ]]; then + simpleurl="$1" + else + basics "$1" # Gets the title, performs one request to imdb and gets the complete url + fi + getInternalID "$simpleurl" # Gets the complete url and performs one request to get the internal id or inform us it does not exist + getMovieStreamUrl "$internalid" # Gets the internal id and performs one request to get the stream url + title="${title//%20/ }" + capitalized_title="$(echo "$title" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')" + message "Loading $capitalized_title" + play # It uses mpv to stream the file + exit 0 +} + ### Program starts here ### # Ensure curl-impersonate is installed @@ -469,6 +506,15 @@ fi [[ "$#" -lt 1 ]] && usage [[ "$#" -gt 3 ]] && usage +[[ "$#" -eq 3 ]] && getSeries "$@" +[[ "$#" -eq 1 ]] \ + && [[ "$1" != "--open" ]] \ + && [[ "$1" != "--menu" ]] \ + && [[ "$1" != "--resume" ]] \ + && [[ "$1" != "--finish" ]] \ + && [[ "$1" != "--select" ]] \ + && [[ "$1" != "--history" ]] \ + && getMovie "$@" [[ "$1" == "--open" ]] && openInBrowser "$@" [[ "$1" == "--menu" ]] && menuSearch @@ -477,49 +523,4 @@ fi [[ "$1" == "--select" ]] && resumeSeries [[ "$1" == "--history" ]] && getHistory -# One arguement and it contains the imdb id -# Two requests to the api -if [[ "$1" == *"tt"* ]] && [[ "$#" -eq 1 ]] && [[ "$1" != "--menu" ]] && [[ "$1" != "--resume" ]] && [[ "$1" != "--finish" ]] && [[ "$1" != "--select" ]] && [[ "$1" != "--history" ]]; then - simpleurl="$1" - getInternalID "$simpleurl" - getMovieStreamUrl "$internalid" - play - exit 0 -fi - -# Series URL -if [[ "$#" -eq 3 ]]; then - # Two requests to the api - basics "$1" - getInternalID "$simpleurl" - season="$2" - episode="$3" - response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")" - streamurl="$(echo "$response" \ - | jq '.[]' \ - | grep "mp4" \ - | grep "${season}x${episode}" \ - | head -n1 \ - | awk -F\" '{print $4}' - )" - title="${title//%20/ }" - capitalized_title="$(echo "$title" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')" - message "Loading $capitalized_title at season $season on episode $episode" - play - exit 0 -fi - -# Movies URL -if [[ "$#" -eq 1 ]] && [[ "$1" != "--menu" ]] && [[ "$1" != "--resume" ]] && [[ "$1" != "--finish" ]] && [[ "$1" != "--select" ]] && [[ "$1" != "--history" ]]; then - # Two requests to the api - basics "$1" # Gets the title, performs one request to imdb and gets the complete url - getInternalID "$simpleurl" # Gets the complete url and performs one request to get the internal id or inform us it does not exist - getMovieStreamUrl "$internalid" # Gets the internal id and performs one request to get the stream url - title="${title//%20/ }" - capitalized_title="$(echo "$title" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')" - message "Loading $capitalized_title" - play # It uses mpv to stream the file - exit 0 -fi - exit 0