bla
This commit is contained in:
74
tv.sh
74
tv.sh
@@ -11,6 +11,18 @@ CHANNELS_FILE="${MPVTV_DATA_DIR}/channels.txt"
|
||||
SCHEDULE_FILE="${MPVTV_DATA_DIR}/schedule.json"
|
||||
CORRECT_SCHEDULE_FILE="${MPVTV_DATA_DIR}/correct_schedule.json"
|
||||
M3U8_FILE="${MPVTV_DATA_DIR}/m3u8.txt"
|
||||
USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0"
|
||||
ACCEPT="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
|
||||
MPV_OPTS='--vo=gpu \
|
||||
--gpu-api=opengl \
|
||||
--opengl-es=yes \
|
||||
--really-quiet \
|
||||
--msg-level=all=no \
|
||||
--no-load-scripts \
|
||||
--profile=sw-fast \
|
||||
--no-ytdl \
|
||||
--http-header-fields="User-Agent: '"$USER_AGENT"'" \
|
||||
--fs'
|
||||
|
||||
mkdir -p "${MPVTV_DATA_DIR}"
|
||||
|
||||
@@ -19,6 +31,26 @@ function usage {
|
||||
exit 0
|
||||
}
|
||||
|
||||
function curlRequest {
|
||||
local url="$1"
|
||||
shift
|
||||
response="$(curl -s -L \
|
||||
-c "$COOKIES_FILE" \
|
||||
-b "$COOKIES_FILE" \
|
||||
"$url" \
|
||||
-A "$USER_AGENT" \
|
||||
-H "$ACCEPT" \
|
||||
"$@"
|
||||
)"
|
||||
|
||||
exit_code="$?"
|
||||
if [[ "$exit_code" -ne 0 ]]; then
|
||||
echo "Error: Failed to execute curl request."
|
||||
exit 1
|
||||
fi
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
function clearFiles {
|
||||
[[ -f "$RESPONSE2_FILE" ]] && rm "$RESPONSE2_FILE"
|
||||
[[ -f "$RESPONSE3_FILE" ]] && rm "$RESPONSE3_FILE"
|
||||
@@ -35,12 +67,7 @@ if [[ "$#" -eq 1 ]]; then
|
||||
fi
|
||||
|
||||
if [[ ! -f "$RESPONSE1_FILE" ]]; then
|
||||
response="$(curl -s -L -c "$COOKIES_FILE" -b "$COOKIES_FILE" \
|
||||
-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" \
|
||||
"$apiurl/areas/gb.html?lang=en"
|
||||
)"
|
||||
|
||||
response="$(curlRequest "$apiurl/areas/gb.html?lang=en")"
|
||||
echo "$response" > "$RESPONSE1_FILE"
|
||||
fi
|
||||
|
||||
@@ -145,12 +172,7 @@ function getChannel {
|
||||
fi
|
||||
|
||||
if [[ ! -f "$RESPONSE2_FILE" ]]; then
|
||||
response2="$(curl -s -L -c "$COOKIES_FILE" -b "$COOKIES_FILE" \
|
||||
-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" \
|
||||
"$CHANNEL_URL"
|
||||
)"
|
||||
|
||||
response2="$(curlRequest "$CHANNEL_URL")"
|
||||
echo "$response2" > "$RESPONSE2_FILE"
|
||||
fi
|
||||
|
||||
@@ -158,12 +180,7 @@ function getChannel {
|
||||
CHANNEL_LIVE="${apiurl}${CHANNEL_LIVE}"
|
||||
|
||||
if [[ ! -f "$RESPONSE3_FILE" ]]; then
|
||||
response3="$(curl -s -L -c "$COOKIES_FILE" -b "$COOKIES_FILE" \
|
||||
-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" \
|
||||
"$CHANNEL_LIVE"
|
||||
)"
|
||||
|
||||
response3="$(curlRequest "$CHANNEL_LIVE")"
|
||||
echo "$response3" > "$RESPONSE3_FILE"
|
||||
fi
|
||||
|
||||
@@ -171,14 +188,10 @@ function getChannel {
|
||||
|
||||
echo "$M3U8_LINK" > "$M3U8_FILE"
|
||||
SCHEDULE="$(grep json "$RESPONSE2_FILE" | sed 's/^[[:space:]]*//' | grep -v "Content-Type" | grep -v "class" | sed 's/\(.*\)<\/a.*/\1/')"
|
||||
[[ -z "$SCHEDULE" ]] && echo "Nothing there" && exit 0
|
||||
|
||||
if [[ ! -f "$SCHEDULE_FILE" ]]; then
|
||||
response4="$(curl -s -L -c "$COOKIES_FILE" -b "$COOKIES_FILE" \
|
||||
-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" \
|
||||
"$SCHEDULE"
|
||||
)"
|
||||
|
||||
response4="$(curlRequest "$SCHEDULE")"
|
||||
echo "$response4" > "$SCHEDULE_FILE"
|
||||
fi
|
||||
|
||||
@@ -192,21 +205,10 @@ function getChannel {
|
||||
|
||||
function play {
|
||||
STREAM_LINK="$(cat "$M3U8_FILE")"
|
||||
MPV_OPTS="--vo=gpu \
|
||||
--gpu-api=opengl \
|
||||
--opengl-es=yes \
|
||||
--really-quiet \
|
||||
--msg-level=all=no \
|
||||
--msg-level=ffmpeg/demuxer=no \
|
||||
--msg-level=ffmpeg=no \
|
||||
--no-load-scripts \
|
||||
--profile=sw-fast \
|
||||
--no-ytdl"
|
||||
notify-send -t 2000 "Loading $CHANNEL_SELECTED"
|
||||
MPVPID="$(pidof mpv | cut -d' ' -f1)"
|
||||
[[ -n "$MPVPID" ]] && kill -s SIGTERM "$MPVPID"
|
||||
|
||||
eval setsid -f mpv "${MPV_OPTS}" "${STREAM_LINK}"
|
||||
eval setsid -f "mpv ${MPV_OPTS} ${STREAM_LINK}"
|
||||
}
|
||||
|
||||
[[ "$1" == "schedule" ]] && getSchedule
|
||||
|
||||
Reference in New Issue
Block a user