Local variables instead of global ones
This commit is contained in:
167
grpoppro
167
grpoppro
@@ -6,8 +6,8 @@ GRPOPPRO_DATA_FILE="$GRPOPPRO_DATA_DIR/lastPlayedSeries"
|
|||||||
GRPOPPRO_PLAYLIST_FILE="$GRPOPPRO_DATA_DIR/lastPlaylistPlayed"
|
GRPOPPRO_PLAYLIST_FILE="$GRPOPPRO_DATA_DIR/lastPlaylistPlayed"
|
||||||
GRPOPPRO_COOKIE_FILE="$GRPOPPRO_DATA_DIR/cookies.txt"
|
GRPOPPRO_COOKIE_FILE="$GRPOPPRO_DATA_DIR/cookies.txt"
|
||||||
GRPOPPRO_HISTORY_FILE="$GRPOPPRO_DATA_DIR/history"
|
GRPOPPRO_HISTORY_FILE="$GRPOPPRO_DATA_DIR/history"
|
||||||
INTERACTIVE="on"
|
GRPOPPRO_INTERACTIVE="on"
|
||||||
DEBUG="on"
|
GRPOPPRO_DEBUG="on"
|
||||||
menu="fuzzel -d -p "
|
menu="fuzzel -d -p "
|
||||||
#menu="fzf -i --prompt="
|
#menu="fzf -i --prompt="
|
||||||
apiurl="https://coverapi.store"
|
apiurl="https://coverapi.store"
|
||||||
@@ -32,10 +32,12 @@ MPV_OPTS='--vo=gpu \
|
|||||||
|
|
||||||
# Display a message
|
# Display a message
|
||||||
function message {
|
function message {
|
||||||
if [[ "$INTERACTIVE" == "on" ]]; then
|
local interactive="$GRPOPPRO_INTERACTIVE"
|
||||||
notify-send -t 2000 "$1"
|
local msg="$1"
|
||||||
|
if [[ "$interactive" == "on" ]]; then
|
||||||
|
notify-send -t 2000 "$msg"
|
||||||
else
|
else
|
||||||
echo -e "\n\t$1"
|
echo -e "\n\t$msg"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +68,7 @@ function curlRequest {
|
|||||||
# Dynamically shift the total number of times needed
|
# Dynamically shift the total number of times needed
|
||||||
shift $((shifts - 1))
|
shift $((shifts - 1))
|
||||||
|
|
||||||
if [[ "$DEBUG" == "off" ]]; then
|
if [[ "$GRPOPPRO_DEBUG" == "off" ]]; then
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
response="$(curl_ff117 -s -L \
|
response="$(curl_ff117 -s -L \
|
||||||
@@ -173,6 +175,11 @@ function getFzfForTermux {
|
|||||||
|
|
||||||
# Retrieve IMDb ID
|
# Retrieve IMDb ID
|
||||||
function getIMDBID {
|
function getIMDBID {
|
||||||
|
|
||||||
|
local title="$1"
|
||||||
|
local response
|
||||||
|
local imdbid
|
||||||
|
|
||||||
response="$(curlRequest "https://www.imdb.com/find/?q=$title")"
|
response="$(curlRequest "https://www.imdb.com/find/?q=$title")"
|
||||||
imdbid="$(echo "$response" \
|
imdbid="$(echo "$response" \
|
||||||
| grep -io ' href=['"'"'"][^"'"'"']*['"'"'"]' \
|
| grep -io ' href=['"'"'"][^"'"'"']*['"'"'"]' \
|
||||||
@@ -189,18 +196,31 @@ function getIMDBID {
|
|||||||
message "Film or show not found in imdb"
|
message "Film or show not found in imdb"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "$imdbid"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prepare basic steps for a request
|
# Prepare basic steps for a request
|
||||||
function basics {
|
function basics {
|
||||||
title="$1"
|
|
||||||
|
local title="$1"
|
||||||
|
local imdbid
|
||||||
|
local simpleurl
|
||||||
|
|
||||||
title="${title// /%20}"
|
title="${title// /%20}"
|
||||||
getIMDBID "$title"
|
imdbid="$(getIMDBID "$title")"
|
||||||
simpleurl="$apiurl/embed/$imdbid/"
|
simpleurl="$apiurl/embed/$imdbid/"
|
||||||
|
|
||||||
|
echo "$simpleurl"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve internal ID
|
# Retrieve internal ID
|
||||||
function getInternalID {
|
function getInternalID {
|
||||||
|
|
||||||
|
local simpleurl="$1"
|
||||||
|
local response
|
||||||
|
local internalid
|
||||||
|
|
||||||
response="$(curlRequest "$simpleurl")"
|
response="$(curlRequest "$simpleurl")"
|
||||||
if echo "$response" | grep -q "404 Not Found"; then
|
if echo "$response" | grep -q "404 Not Found"; then
|
||||||
message "Non valid response"
|
message "Non valid response"
|
||||||
@@ -215,11 +235,19 @@ function getInternalID {
|
|||||||
| awk '{print $5}' \
|
| awk '{print $5}' \
|
||||||
| awk -F\' '{print $2}'
|
| awk -F\' '{print $2}'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
echo "$internalid"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve movie stream URL
|
# Retrieve movie stream URL
|
||||||
function getMovieStreamUrl {
|
function getMovieStreamUrl {
|
||||||
|
local internalid="$1"
|
||||||
|
local PHPSESSID
|
||||||
PHPSESSID="$(grep 'PHPSESSID' "$GRPOPPRO_COOKIE_FILE" | awk '{print $NF}')"
|
PHPSESSID="$(grep 'PHPSESSID' "$GRPOPPRO_COOKIE_FILE" | awk '{print $NF}')"
|
||||||
|
|
||||||
|
local response
|
||||||
|
local streamurl
|
||||||
|
|
||||||
local headers=(
|
local headers=(
|
||||||
'-H Accept-Encoding: gzip, deflate, br, zstd'
|
'-H Accept-Encoding: gzip, deflate, br, zstd'
|
||||||
'-H Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
|
'-H Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
|
||||||
@@ -247,22 +275,30 @@ function getMovieStreamUrl {
|
|||||||
| sed 's/\\//g' \
|
| sed 's/\\//g' \
|
||||||
| grep -oP 'file:"\K[^"]+'
|
| grep -oP 'file:"\K[^"]+'
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
echo "$streamurl"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stream the video
|
# Stream the video
|
||||||
function play {
|
function play {
|
||||||
|
local streamurl="$1"
|
||||||
|
|
||||||
if [[ "$player" == "mpv" ]]; then
|
if [[ "$player" == "mpv" ]]; then
|
||||||
MPVPID="$(pidof mpv | cut -d' ' -f1)"
|
MPVPID="$(pidof mpv | cut -d' ' -f1)"
|
||||||
[[ -n "$MPVPID" ]] && kill -s SIGTERM "$MPVPID"
|
[[ -n "$MPVPID" ]] && kill -s SIGTERM "$MPVPID"
|
||||||
player="mpv --save-position-on-quit ${MPV_OPTS}"
|
player="mpv --save-position-on-quit ${MPV_OPTS}"
|
||||||
fi
|
fi
|
||||||
[[ "$OSTYPE" != "linux-gnu" ]] && INTERACTIVE="off" && streamurl="${streamurl//https/http}"
|
[[ "$OSTYPE" != "linux-gnu" ]] && GRPOPPRO_INTERACTIVE="off" && streamurl="${streamurl//https/http}"
|
||||||
# No setsid -f here because we need to wait for mpv to finish
|
# No setsid -f here because we need to wait for mpv to finish
|
||||||
eval "$player" "$streamurl"
|
eval "$player" "$streamurl"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dump data to files
|
# Dump data to files
|
||||||
function dumpData {
|
function dumpData {
|
||||||
|
local title="$1"
|
||||||
|
local seasonEpisode="$2"
|
||||||
|
local streamurl="$3"
|
||||||
|
|
||||||
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"
|
||||||
@@ -273,17 +309,31 @@ function dumpData {
|
|||||||
|
|
||||||
# Source data from files
|
# Source data from files
|
||||||
function sourceData {
|
function sourceData {
|
||||||
|
local lastSeriesPlayed
|
||||||
|
local lastSeasonEpisodePlayed
|
||||||
|
local lastEpisodePlayedURL
|
||||||
|
|
||||||
if [[ -f "$GRPOPPRO_DATA_FILE" ]]; then
|
if [[ -f "$GRPOPPRO_DATA_FILE" ]]; then
|
||||||
lastSeriesPlayed="$(sed -n 1p "$GRPOPPRO_DATA_FILE")"
|
lastSeriesPlayed="$(sed -n 1p "$GRPOPPRO_DATA_FILE")"
|
||||||
lastSeasonEpisodePlayed="$(sed -n 2p "$GRPOPPRO_DATA_FILE")"
|
lastSeasonEpisodePlayed="$(sed -n 2p "$GRPOPPRO_DATA_FILE")"
|
||||||
lastEpisodePlayedURL="$(sed -n 3p "$GRPOPPRO_DATA_FILE")"
|
lastEpisodePlayedURL="$(sed -n 3p "$GRPOPPRO_DATA_FILE")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "$lastSeriesPlayed|$lastSeasonEpisodePlayed|$lastEpisodePlayedURL"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Perform menu search
|
# Perform menu search
|
||||||
function menuSearch {
|
function menuSearch {
|
||||||
|
local title
|
||||||
|
local imdbid
|
||||||
|
local simpleurl
|
||||||
|
local internalid
|
||||||
|
local response
|
||||||
|
local seasonEpisode
|
||||||
|
local streamurl
|
||||||
|
|
||||||
# Two requests to the api
|
# Two requests to the api
|
||||||
if [[ "$INTERACTIVE" == "on" ]]; then
|
if [[ "$GRPOPPRO_INTERACTIVE" == "on" ]]; then
|
||||||
title=$(echo "" | wofi --dmenu --insensitive --prompt="Search Series" --width=300 --height=50)
|
title=$(echo "" | wofi --dmenu --insensitive --prompt="Search Series" --width=300 --height=50)
|
||||||
else
|
else
|
||||||
read -r -p "Search Series: " title
|
read -r -p "Search Series: " title
|
||||||
@@ -293,9 +343,9 @@ function menuSearch {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
title="${title// /%20}"
|
title="${title// /%20}"
|
||||||
getIMDBID "$title"
|
imdbid="$(getIMDBID "$title")"
|
||||||
simpleurl="$apiurl/embed/$imdbid/"
|
simpleurl="$apiurl/embed/$imdbid/"
|
||||||
getInternalID "$simpleurl"
|
internalid="$(getInternalID "$simpleurl")"
|
||||||
response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")"
|
response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")"
|
||||||
echo "$response" > "$GRPOPPRO_PLAYLIST_FILE"
|
echo "$response" > "$GRPOPPRO_PLAYLIST_FILE"
|
||||||
title="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" \
|
title="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" \
|
||||||
@@ -320,8 +370,8 @@ function menuSearch {
|
|||||||
| head -n1 \
|
| head -n1 \
|
||||||
| awk -F\" '{print $4}'
|
| awk -F\" '{print $4}'
|
||||||
)"
|
)"
|
||||||
dumpData "$title" "$seasonEpisode"
|
dumpData "$title" "$seasonEpisode" "$streamurl"
|
||||||
play
|
play "$streamurl"
|
||||||
resume
|
resume
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,11 +382,16 @@ function resume {
|
|||||||
message "Nothing to resume"
|
message "Nothing to resume"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
sourceData
|
local data
|
||||||
title=$lastSeriesPlayed
|
local title
|
||||||
|
data="$(sourceData)"
|
||||||
|
title="$(echo "$data" | cut -d '|' -f1)"
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
sourceData
|
data="$(sourceData)"
|
||||||
|
local seasonEpisode
|
||||||
|
local lastSeasonEpisodePlayed
|
||||||
|
lastSeasonEpisodePlayed="$(echo "$data" | cut -d '|' -f2)"
|
||||||
seasonEpisode="$(jq '.[]' "$GRPOPPRO_PLAYLIST_FILE" \
|
seasonEpisode="$(jq '.[]' "$GRPOPPRO_PLAYLIST_FILE" \
|
||||||
| grep "mp4" \
|
| grep "mp4" \
|
||||||
| awk -F/ '{print $NF}' \
|
| awk -F/ '{print $NF}' \
|
||||||
@@ -348,13 +403,14 @@ function resume {
|
|||||||
message "Nothing Selected"
|
message "Nothing Selected"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
local streamurl
|
||||||
streamurl="$(jq '.[]' "$GRPOPPRO_PLAYLIST_FILE" \
|
streamurl="$(jq '.[]' "$GRPOPPRO_PLAYLIST_FILE" \
|
||||||
| grep "${seasonEpisode}" \
|
| grep "${seasonEpisode}" \
|
||||||
| head -n1 \
|
| head -n1 \
|
||||||
| awk -F\" '{print $4}'
|
| awk -F\" '{print $4}'
|
||||||
)"
|
)"
|
||||||
dumpData "$title" "$seasonEpisode"
|
dumpData "$title" "$seasonEpisode" "$streamurl"
|
||||||
play
|
play "$streamurl"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +423,7 @@ function resumeSeries {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local resume_series
|
||||||
resume_series="$(awk -F'|' '{print $1}' "$GRPOPPRO_HISTORY_FILE" \
|
resume_series="$(awk -F'|' '{print $1}' "$GRPOPPRO_HISTORY_FILE" \
|
||||||
| sort \
|
| sort \
|
||||||
| uniq \
|
| uniq \
|
||||||
@@ -377,29 +434,32 @@ function resumeSeries {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local resume_episode
|
||||||
resume_episode="$(grep "^$resume_series|" "$GRPOPPRO_HISTORY_FILE" | awk -F'|' '{print $2}')"
|
resume_episode="$(grep "^$resume_series|" "$GRPOPPRO_HISTORY_FILE" | awk -F'|' '{print $2}')"
|
||||||
if [[ -n "$resume_episode" ]]; then
|
if [[ -n "$resume_episode" ]]; then
|
||||||
message "Continuing $resume_series from $resume_episode"
|
message "Continuing $resume_series from $resume_episode"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local resume_streamurl
|
||||||
resume_streamurl=$(grep "^$resume_series|$resume_episode|" "$GRPOPPRO_HISTORY_FILE" | awk -F'|' '{print $3}')
|
resume_streamurl=$(grep "^$resume_series|$resume_episode|" "$GRPOPPRO_HISTORY_FILE" | awk -F'|' '{print $3}')
|
||||||
title="$resume_series"
|
local title="$resume_series"
|
||||||
|
local lastTitle
|
||||||
lastTitle="$(sed -n 1p "$GRPOPPRO_DATA_FILE")"
|
lastTitle="$(sed -n 1p "$GRPOPPRO_DATA_FILE")"
|
||||||
if [[ ! "$title" == "$lastTitle" ]]; then
|
if [[ ! "$title" == "$lastTitle" ]]; then
|
||||||
title="${title// /%20}"
|
title="${title// /%20}"
|
||||||
getIMDBID "$title"
|
imdbid="$(getIMDBID "$title")"
|
||||||
simpleurl="$apiurl/embed/$imdbid/"
|
simpleurl="$apiurl/embed/$imdbid/"
|
||||||
getInternalID "$simpleurl"
|
internalid="$(getInternalID "$simpleurl")"
|
||||||
response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")"
|
response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")"
|
||||||
echo "$response" > "$GRPOPPRO_PLAYLIST_FILE"
|
echo "$response" > "$GRPOPPRO_PLAYLIST_FILE"
|
||||||
fi
|
fi
|
||||||
title="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | head -n1 | awk -F/ '{print $(NF-1)}')"
|
title="$(grep "mp4" "$GRPOPPRO_PLAYLIST_FILE" | head -n1 | awk -F/ '{print $(NF-1)}')"
|
||||||
title="${title//_/ }"
|
title="${title//_/ }"
|
||||||
title="${title//-/ }"
|
title="${title//-/ }"
|
||||||
seasonEpisode="$resume_episode"
|
local seasonEpisode="$resume_episode"
|
||||||
streamurl="$resume_streamurl"
|
local streamurl="$resume_streamurl"
|
||||||
dumpData "$title" "$seasonEpisode"
|
dumpData "$title" "$seasonEpisode" "$streamurl"
|
||||||
play
|
play "$streamurl"
|
||||||
resume
|
resume
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,15 +470,22 @@ function resumeUnfinishedEpisode {
|
|||||||
message "Nothing to resume"
|
message "Nothing to resume"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
sourceData
|
local data
|
||||||
|
local lastSeriesPlayed
|
||||||
|
local lastSeasonEpisodePlayed
|
||||||
|
local lastEpisodePlayedURL
|
||||||
|
data="$(sourceData)"
|
||||||
|
lastSeriesPlayed="$(echo "$data" | cut -d '|' -f1)"
|
||||||
|
lastSeasonEpisodePlayed="$(echo "$data" | cut -d '|' -f2)"
|
||||||
|
lastEpisodePlayedURL="$(echo "$data" | cut -d '|' -f3)"
|
||||||
message "Continuing $lastSeriesPlayed from $lastSeasonEpisodePlayed"
|
message "Continuing $lastSeriesPlayed from $lastSeasonEpisodePlayed"
|
||||||
streamurl="$lastEpisodePlayedURL"
|
local streamurl="$lastEpisodePlayedURL"
|
||||||
if [[ "$player" == "mpv" ]]; then
|
if [[ "$player" == "mpv" ]]; then
|
||||||
MPVPID="$(pidof mpv | cut -d' ' -f1)"
|
MPVPID="$(pidof mpv | cut -d' ' -f1)"
|
||||||
[[ -n "$MPVPID" ]] && kill -s SIGTERM "$MPVPID"
|
[[ -n "$MPVPID" ]] && kill -s SIGTERM "$MPVPID"
|
||||||
player="mpv --resume-playback ${MPV_OPTS}"
|
player="mpv --resume-playback ${MPV_OPTS}"
|
||||||
fi
|
fi
|
||||||
[[ "$OSTYPE" != "linux-gnu" ]] && INTERACTIVE="off" && streamurl="${streamurl//https/http}"
|
[[ "$OSTYPE" != "linux-gnu" ]] && GRPOPPRO_INTERACTIVE="off" && streamurl="${streamurl//https/http}"
|
||||||
# No setsid -f here because we need to wait for mpv to finish
|
# No setsid -f here because we need to wait for mpv to finish
|
||||||
eval "$player" "$streamurl"
|
eval "$player" "$streamurl"
|
||||||
resume
|
resume
|
||||||
@@ -426,9 +493,13 @@ function resumeUnfinishedEpisode {
|
|||||||
|
|
||||||
# Open in browser to watch
|
# Open in browser to watch
|
||||||
function openInBrowser {
|
function openInBrowser {
|
||||||
|
local title="$2"
|
||||||
|
local simpleurl
|
||||||
|
|
||||||
# One request to the api
|
# One request to the api
|
||||||
basics "$2"
|
simpleurl="$(basics "$title")"
|
||||||
getInternalID "$simpleurl"
|
local internalid
|
||||||
|
internalid="$(getInternalID "$simpleurl")"
|
||||||
xdg-open "$simpleurl"
|
xdg-open "$simpleurl"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@@ -439,6 +510,7 @@ function getHistory {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local history
|
||||||
history="$(awk -F'|' '{print $1,":<=> At =>",$2}' "$GRPOPPRO_HISTORY_FILE" | column -t -s':')"
|
history="$(awk -F'|' '{print $1,":<=> At =>",$2}' "$GRPOPPRO_HISTORY_FILE" | column -t -s':')"
|
||||||
|
|
||||||
message "$history"
|
message "$history"
|
||||||
@@ -446,12 +518,18 @@ function getHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSeries {
|
function getSeries {
|
||||||
|
local title="$1"
|
||||||
|
local season="$2"
|
||||||
|
local episode="$3"
|
||||||
|
local simpleurl
|
||||||
|
simpleurl="$(basics "$title")"
|
||||||
|
local internalid
|
||||||
|
internalid="$(getInternalID "$simpleurl")"
|
||||||
|
local response
|
||||||
|
|
||||||
# Two requests to the api
|
# Two requests to the api
|
||||||
basics "$1"
|
|
||||||
getInternalID "$simpleurl"
|
|
||||||
season="$2"
|
|
||||||
episode="$3"
|
|
||||||
response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")"
|
response="$(curlRequest "$apiurl/uploads/playlists/$internalid.txt")"
|
||||||
|
local streamurl
|
||||||
streamurl="$(echo "$response" \
|
streamurl="$(echo "$response" \
|
||||||
| jq '.[]' \
|
| jq '.[]' \
|
||||||
| grep "mp4" \
|
| grep "mp4" \
|
||||||
@@ -460,25 +538,30 @@ function getSeries {
|
|||||||
| awk -F\" '{print $4}'
|
| awk -F\" '{print $4}'
|
||||||
)"
|
)"
|
||||||
title="${title//%20/ }"
|
title="${title//%20/ }"
|
||||||
|
local capitalized_title
|
||||||
capitalized_title="$(echo "$title" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')"
|
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"
|
message "Loading $capitalized_title at season $season on episode $episode"
|
||||||
play
|
play "$streamurl"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMovie {
|
function getMovie {
|
||||||
|
local simpleurl
|
||||||
# Two requests to the api
|
# Two requests to the api
|
||||||
if [[ "$1" == *"tt"* ]]; then
|
if [[ "$1" == *"tt"* ]]; then
|
||||||
simpleurl="$1"
|
simpleurl="$1"
|
||||||
else
|
else
|
||||||
basics "$1" # Gets the title, performs one request to imdb and gets the complete url
|
simpleurl="$(basics "$1")" # Gets the title, performs one request to imdb and gets the complete url
|
||||||
fi
|
fi
|
||||||
getInternalID "$simpleurl" # Gets the complete url and performs one request to get the internal id or inform us it does not exist
|
local internalid
|
||||||
getMovieStreamUrl "$internalid" # Gets the internal id and performs one request to get the stream url
|
internalid="$(getInternalID "$simpleurl")" # Gets the complete url and performs one request to get the internal id or inform us it does not exist
|
||||||
title="${title//%20/ }"
|
local streamurl
|
||||||
|
streamurl="$(getMovieStreamUrl "$internalid")" # Gets the internal id and performs one request to get the stream url
|
||||||
|
local title="${title//%20/ }"
|
||||||
|
local capitalized_title
|
||||||
capitalized_title="$(echo "$title" | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1')"
|
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"
|
message "Loading $capitalized_title"
|
||||||
play # It uses mpv to stream the file
|
play "$streamurl" # It uses mpv to stream the file
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +585,7 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare the necessary steps for Termux environment
|
# Prepare the necessary steps for Termux environment
|
||||||
[[ "$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" ]] && GRPOPPRO_INTERACTIVE="off" && menu="fzf -i --prompt=seasonXepisode" && player="am start -n is.xyz.mpv/.MPVActivity -a android.intent.action.VIEW -d" && getFzfForTermux
|
||||||
|
|
||||||
[[ "$#" -lt 1 ]] && usage
|
[[ "$#" -lt 1 ]] && usage
|
||||||
[[ "$#" -gt 3 ]] && usage
|
[[ "$#" -gt 3 ]] && usage
|
||||||
|
|||||||
Reference in New Issue
Block a user