Whatever will be, will be 8{

This commit is contained in:
2024-12-24 16:20:29 +02:00
parent eb8260fc9c
commit f0fad26a0d
2 changed files with 37 additions and 13 deletions

View File

@@ -53,6 +53,11 @@ To continue unfinished series episode
grpoppro --finish
```
To open in browser
```sh
grpoppro --open \"Name of movie or tv series\"
```
## Dependencies
* curl

View File

@@ -63,7 +63,7 @@ function getInternalID() {
"$simpleurl"
)"
if echo "$response" | grep -q "id='el-content'></div>"; then
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "No file found" || echo -e "\n\tNo file found" && exit
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "No file found" || echo -e "\n\tNo file found" && exit 0
fi
internalid="$(echo "$response" | grep news_id | awk '{print $5}' | awk -F\' '{print $2}')"
}
@@ -77,13 +77,13 @@ function getIMDBID() {
# 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
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Film or show not found in imdb" || echo -e "\n\tFilm or show not found in imdb"
exit
exit 0
fi
}
function usage {
echo -e "\n\tUsage: $(basename "$0") \"name of film or show\" [season] [episode(ex 01 02 .. 10 11)]\n\tOr $(basename "$0") [--menu|--resume|--finish]"
exit
echo -e "\n\tUsage:\n\n\t$(basename "$0") \"name of film or show\" [season] [episode(ex 01 02 .. 10 11)]\n\tOr $(basename "$0") [--menu|--resume|--finish]\n\tOr $(basename "$0") --open \"name of film or show\""
exit 0
}
function play {
@@ -105,7 +105,6 @@ function sourceData {
[[ "$#" -lt 1 ]] && usage
[[ "$#" -gt 3 ]] && usage
[[ "$#" -eq 2 ]] && usage
#Standard Stuff
@@ -120,7 +119,10 @@ function menuSearch {
# Two requests to the api
[[ "$INTERACTIVE" == "on" ]] && title=$(echo "" | wofi --dmenu --insensitive --prompt="Search Series" --width=300 --height=50)
[[ "$INTERACTIVE" == "off" ]] && [[ -z "$title" ]] && read -r -p "Search Series: " title
[[ -z "$title" ]] && exit
if [[ -z "$title" ]]; then
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing given" || echo "Nothing given"
exit 0
fi
title="${title// /%20}"
getIMDBID "$title"
simpleurl="$apiurl/embed/$imdbid/"
@@ -139,7 +141,7 @@ function menuSearch {
seasonEpisode="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | awk -F\" '{print $8}' | awk -F/ '{print $NF}' | awk -F. '{print $1}' | eval "$menu"\""$title"\")"
if [[ -z "$seasonEpisode" ]]; then
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing Selected" || echo "Nothing Selected"
exit
exit 0
fi
streamurl="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | grep "${seasonEpisode}" | head -n1 | awk -F\" '{print $8}')"
dumpData "$title" "$seasonEpisode"
@@ -149,7 +151,10 @@ function menuSearch {
function resume {
# Zero requests to the api
[ ! -f "$GRPOPPRO_DATA_FILE" ] && echo "Nothing to resume" && exit
if [[ ! -f "$GRPOPPRO_DATA_FILE" ]]; then
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing to resume" || echo "Nothing to resume"
exit 0
fi
sourceData
title=$lastSeriesPlayed
while true
@@ -158,7 +163,7 @@ function resume {
seasonEpisode="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | awk -F\" '{print $8}' | awk -F/ '{print $NF}' | awk -F. '{print $1}' | sed -n -e "0,/$lastSeasonEpisodePlayed/!p" | eval "$menu"\""$title"\")"
if [[ -z "$seasonEpisode" ]]; then
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing Selected" || echo "Nothing Selected"
exit
exit 0
fi
streamurl="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | grep "${seasonEpisode}" | head -n1 | awk -F\" '{print $8}')"
dumpData "$title" "$seasonEpisode"
@@ -168,7 +173,10 @@ function resume {
function resumeUnfinishedEpisode {
# Zero requests to the api
[ ! -f "$GRPOPPRO_DATA_FILE" ] && echo "Nothing to resume" && exit
if [[ ! -f "$GRPOPPRO_DATA_FILE" ]]; then
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing to resume" || echo "Nothing to resume"
exit 0
fi
sourceData
streamurl="$lastEpisodePlayedURL"
[[ "$OSTYPE" != "linux-gnu" ]] && INTERACTIVE="off" && streamurl="${streamurl//https/http}"
@@ -177,6 +185,15 @@ function resumeUnfinishedEpisode {
resume
}
function openInBrowser {
# One request to the api
basics "$2"
getInternalID "$simpleurl"
xdg-open "$simpleurl"
exit 0
}
[[ "$1" == "--open" ]] && openInBrowser "$@"
[[ "$1" == "--menu" ]] && menuSearch
[[ "$1" == "--resume" ]] && resume
[[ "$1" == "--finish" ]] && resumeUnfinishedEpisode
@@ -187,7 +204,7 @@ if [[ "$1" == *"tt"* ]] && [[ "$#" -eq 1 ]] && [[ "$1" != "--menu" ]] && [[ "$1"
getInternalID "$simpleurl"
getMovieStreamUrl "$internalid"
play
exit
exit 0
fi
# Series URL
@@ -205,7 +222,7 @@ if [[ "$#" -eq 3 ]]; then
-H "Upgrade-Insecure-Requests: 1" \
"$apiurl/uploads/playlists/$internalid.txt" | grep "mp4" | grep "${season}x${episode}" | head -n1 | awk -F\" '{print $8}')"
play
exit
exit 0
fi
# Movies URL
@@ -215,5 +232,7 @@ if [[ "$#" -eq 1 ]] && [[ "$1" != "--menu" ]] && [[ "$1" != "--resume" ]]; then
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
play # It uses mpv to stream the file
exit
exit 0
fi
exit 0