TDD: 1, Me: 0
This commit is contained in:
40
grpoppro
40
grpoppro
@@ -27,9 +27,17 @@ function getFzfForTermux {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function message {
|
||||||
|
if [[ "$INTERACTIVE" == "on" ]]; then
|
||||||
|
notify-send -t 2000 "$1"
|
||||||
|
else
|
||||||
|
echo -e "\n\t$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
[[ "$OSTYPE" != "linux-gnu" ]] && INTERACTIVE="off" && menu="fzf -i --prompt=seasonXepisode" && player="am start -n is.xyz.mpv/.MPVActivity -a android.intent.action.VIEW -d" && getFzfForTermux
|
[[ "$OSTYPE" != "linux-gnu" ]] && INTERACTIVE="off" && menu="fzf -i --prompt=seasonXepisode" && player="am start -n is.xyz.mpv/.MPVActivity -a android.intent.action.VIEW -d" && getFzfForTermux
|
||||||
|
|
||||||
function getMovieStreamUrl() {
|
function getMovieStreamUrl {
|
||||||
PHPSESSID="$(grep 'PHPSESSID' "$GRPOPPRO_COOKIE_FILE" | awk '{print $NF}')"
|
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 \
|
streamurl="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" "$apiurl/engine/ajax/controller.php" --compressed -X POST \
|
||||||
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0' \
|
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0' \
|
||||||
@@ -53,7 +61,7 @@ function getMovieStreamUrl() {
|
|||||||
)"
|
)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInternalID() {
|
function getInternalID {
|
||||||
response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \
|
response="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \
|
||||||
-A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0" \
|
-A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0" \
|
||||||
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
|
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
|
||||||
@@ -63,12 +71,13 @@ function getInternalID() {
|
|||||||
"$simpleurl"
|
"$simpleurl"
|
||||||
)"
|
)"
|
||||||
if echo "$response" | grep -q "id='el-content'></div>"; then
|
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 0
|
message "No file found"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
internalid="$(echo "$response" | grep news_id | awk '{print $5}' | awk -F\' '{print $2}')"
|
internalid="$(echo "$response" | grep news_id | awk '{print $5}' | awk -F\' '{print $2}')"
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIMDBID() {
|
function getIMDBID {
|
||||||
imdbid="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \
|
imdbid="$(curl -s -L -c "$GRPOPPRO_COOKIE_FILE" -b "$GRPOPPRO_COOKIE_FILE" \
|
||||||
-A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0" \
|
-A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0" \
|
||||||
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
|
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
|
||||||
@@ -76,7 +85,7 @@ 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/"//')"
|
# 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
|
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"
|
message "Film or show not found in imdb"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -92,15 +101,19 @@ function play {
|
|||||||
eval "$player" "$streamurl"
|
eval "$player" "$streamurl"
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpData() {
|
function dumpData {
|
||||||
echo "$title" > "$GRPOPPRO_DATA_FILE"
|
echo "$title" > "$GRPOPPRO_DATA_FILE"
|
||||||
echo "$seasonEpisode" >> "$GRPOPPRO_DATA_FILE"
|
echo "$seasonEpisode" >> "$GRPOPPRO_DATA_FILE"
|
||||||
echo "$streamurl" >> "$GRPOPPRO_DATA_FILE"
|
echo "$streamurl" >> "$GRPOPPRO_DATA_FILE"
|
||||||
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Last Played -> $seasonEpisode" || echo "Last Played -> $seasonEpisode"
|
message "Last Played -> $seasonEpisode"
|
||||||
}
|
}
|
||||||
|
|
||||||
function sourceData {
|
function sourceData {
|
||||||
[ -f "$GRPOPPRO_DATA_FILE" ] && lastSeasonEpisodePlayed="$(sed -n 2p "$GRPOPPRO_DATA_FILE")" && lastSeriesPlayed="$(sed -n 1p "$GRPOPPRO_DATA_FILE")" && lastEpisodePlayedURL="$(sed -n 3p "$GRPOPPRO_DATA_FILE")"
|
if [[ -f "$GRPOPPRO_DATA_FILE" ]]; then
|
||||||
|
lastSeriesPlayed="$(sed -n 1p "$GRPOPPRO_DATA_FILE")"
|
||||||
|
lastSeasonEpisodePlayed="$(sed -n 2p "$GRPOPPRO_DATA_FILE")"
|
||||||
|
lastEpisodePlayedURL="$(sed -n 3p "$GRPOPPRO_DATA_FILE")"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ "$#" -lt 1 ]] && usage
|
[[ "$#" -lt 1 ]] && usage
|
||||||
@@ -120,7 +133,7 @@ function menuSearch {
|
|||||||
[[ "$INTERACTIVE" == "on" ]] && title=$(echo "" | wofi --dmenu --insensitive --prompt="Search Series" --width=300 --height=50)
|
[[ "$INTERACTIVE" == "on" ]] && title=$(echo "" | wofi --dmenu --insensitive --prompt="Search Series" --width=300 --height=50)
|
||||||
[[ "$INTERACTIVE" == "off" ]] && [[ -z "$title" ]] && read -r -p "Search Series: " title
|
[[ "$INTERACTIVE" == "off" ]] && [[ -z "$title" ]] && read -r -p "Search Series: " title
|
||||||
if [[ -z "$title" ]]; then
|
if [[ -z "$title" ]]; then
|
||||||
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing given" || echo "Nothing given"
|
message "Nothing given"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
title="${title// /%20}"
|
title="${title// /%20}"
|
||||||
@@ -140,7 +153,7 @@ function menuSearch {
|
|||||||
title="${title//_/ }"
|
title="${title//_/ }"
|
||||||
seasonEpisode="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | awk -F\" '{print $8}' | awk -F/ '{print $NF}' | awk -F. '{print $1}' | eval "$menu"\""$title"\")"
|
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
|
if [[ -z "$seasonEpisode" ]]; then
|
||||||
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing Selected" || echo "Nothing Selected"
|
message "Nothing Selected"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
streamurl="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | grep "${seasonEpisode}" | head -n1 | awk -F\" '{print $8}')"
|
streamurl="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | grep "${seasonEpisode}" | head -n1 | awk -F\" '{print $8}')"
|
||||||
@@ -152,7 +165,7 @@ function menuSearch {
|
|||||||
function resume {
|
function resume {
|
||||||
# Zero requests to the api
|
# Zero requests to the api
|
||||||
if [[ ! -f "$GRPOPPRO_DATA_FILE" ]]; then
|
if [[ ! -f "$GRPOPPRO_DATA_FILE" ]]; then
|
||||||
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing to resume" || echo "Nothing to resume"
|
message "Nothing to resume"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
sourceData
|
sourceData
|
||||||
@@ -162,7 +175,7 @@ function resume {
|
|||||||
sourceData
|
sourceData
|
||||||
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"\")"
|
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
|
if [[ -z "$seasonEpisode" ]]; then
|
||||||
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing Selected" || echo "Nothing Selected"
|
message "Nothing Selected"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
streamurl="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | grep "${seasonEpisode}" | head -n1 | awk -F\" '{print $8}')"
|
streamurl="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | grep "${seasonEpisode}" | head -n1 | awk -F\" '{print $8}')"
|
||||||
@@ -174,7 +187,7 @@ function resume {
|
|||||||
function resumeUnfinishedEpisode {
|
function resumeUnfinishedEpisode {
|
||||||
# Zero requests to the api
|
# Zero requests to the api
|
||||||
if [[ ! -f "$GRPOPPRO_DATA_FILE" ]]; then
|
if [[ ! -f "$GRPOPPRO_DATA_FILE" ]]; then
|
||||||
[[ "$INTERACTIVE" == "on" ]] && notify-send -t 2000 "Nothing to resume" || echo "Nothing to resume"
|
message "Nothing to resume"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
sourceData
|
sourceData
|
||||||
@@ -199,6 +212,7 @@ function openInBrowser {
|
|||||||
[[ "$1" == "--finish" ]] && resumeUnfinishedEpisode
|
[[ "$1" == "--finish" ]] && resumeUnfinishedEpisode
|
||||||
|
|
||||||
# One arguement and it contains the imdb id
|
# One arguement and it contains the imdb id
|
||||||
|
# Two requests to the api
|
||||||
if [[ "$1" == *"tt"* ]] && [[ "$#" -eq 1 ]] && [[ "$1" != "--menu" ]] && [[ "$1" != "--resume" ]]; then
|
if [[ "$1" == *"tt"* ]] && [[ "$#" -eq 1 ]] && [[ "$1" != "--menu" ]] && [[ "$1" != "--resume" ]]; then
|
||||||
simpleurl="$1"
|
simpleurl="$1"
|
||||||
getInternalID "$simpleurl"
|
getInternalID "$simpleurl"
|
||||||
|
|||||||
Reference in New Issue
Block a user