Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # REQUIREMENTS
- # curl - sudo apt install curl
- # jq - sudo apt install jq
- # mpv - sudo apt install mpv
- # INSTRUCTIONS
- # FILL IN refresh_token (only once)
- # How to get it;
- # https://files.catbox.moe/e3bg5m.png
- refresh_token=""
- if [ -z "$refresh_token" ]
- then
- echo "Add refresh_token"
- exit
- fi
- # use the new refresh_token instead of above
- if [ -f .refresh_token ]; then
- refresh_token=$(cat .refresh_token)
- fi
- # get your access and refresh tokens
- token_response=$(curl -s 'https://securetoken.googleapis.com/v1/token?key=YOUR_API_KEY' \
- -X POST --data-raw 'grant_type=refresh_token&refresh_token='$refresh_token'' --compressed)
- echo "$token_response" | jq -r '.access_token' > .access_token
- echo "$token_response" | jq -r '.refresh_token' > .refresh_token
- while true; do
- get_feeds=$(curl -s 'https://www.fishtank.live/api/live-streams' \
- -H 'AuthToken: '$(cat .access_token)'' \
- --compressed | jq -r '.liveStreams | .[] | "\(.name)|\(.url)"')
- # array to store the PIDs of mpv processes
- declare -a pids
- while read -r line; do
- feed_token=$(echo "$line" | cut -d '|' -f2)
- # check if a process with the same PID is already running
- if [[ " ${pids[@]} " =~ " $$ " ]]; then
- echo "Already running PID: $$"
- else
- # start the stream and save the PID of the mpv process
- mpv --really-quiet --no-terminal "https://customer-jwh6wms36w6479b4.cloudflarestream.com/$feed_token/manifest/video.m3u8?parentOrigin=https%3A%2F%2Fwww.fishtank.live" &
- pids+=($!)
- fi
- done <<< "$get_feeds"
- # wait for all mpv processes to exit
- for pid in "${pids[@]}"; do
- wait $pid
- done
- # clear the PID array
- pids=()
- # sleep for 10 seconds before checking the streams again
- sleep 10
- done
Add Comment
Please, Sign In to add comment