Guest User

v4

a guest
Apr 28th, 2023
5,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # REQUIREMENTS
  4. # curl - sudo apt install curl
  5. # jq - sudo apt install jq
  6. # mpv - sudo apt install mpv
  7.  
  8. # INSTRUCTIONS
  9. # FILL IN refresh_token (only once)
  10. # How to get it;
  11. # https://files.catbox.moe/e3bg5m.png
  12.  
  13. refresh_token=""
  14.  
  15. if [ -z "$refresh_token" ]
  16. then
  17. echo "Add refresh_token"
  18. exit
  19. fi
  20.  
  21. # use the new refresh_token instead of above
  22. if [ -f .refresh_token ]; then
  23. refresh_token=$(cat .refresh_token)
  24. fi
  25.  
  26. # get your access and refresh tokens
  27. token_response=$(curl -s 'https://securetoken.googleapis.com/v1/token?key=YOUR_API_KEY' \
  28. -X POST --data-raw 'grant_type=refresh_token&refresh_token='$refresh_token'' --compressed)
  29. echo "$token_response" | jq -r '.access_token' > .access_token
  30. echo "$token_response" | jq -r '.refresh_token' > .refresh_token
  31.  
  32. while true; do
  33. get_feeds=$(curl -s 'https://www.fishtank.live/api/live-streams' \
  34. -H 'AuthToken: '$(cat .access_token)'' \
  35. --compressed | jq -r '.liveStreams | .[] | "\(.name)|\(.url)"')
  36.  
  37. # array to store the PIDs of mpv processes
  38. declare -a pids
  39.  
  40. while read -r line; do
  41. feed_token=$(echo "$line" | cut -d '|' -f2)
  42. # check if a process with the same PID is already running
  43. if [[ " ${pids[@]} " =~ " $$ " ]]; then
  44. echo "Already running PID: $$"
  45. else
  46. # start the stream and save the PID of the mpv process
  47. mpv --really-quiet --no-terminal "https://customer-jwh6wms36w6479b4.cloudflarestream.com/$feed_token/manifest/video.m3u8?parentOrigin=https%3A%2F%2Fwww.fishtank.live" &
  48. pids+=($!)
  49. fi
  50. done <<< "$get_feeds"
  51.  
  52. # wait for all mpv processes to exit
  53. for pid in "${pids[@]}"; do
  54. wait $pid
  55. done
  56.  
  57. # clear the PID array
  58. pids=()
  59.  
  60. # sleep for 10 seconds before checking the streams again
  61. sleep 10
  62. done
  63.  
Add Comment
Please, Sign In to add comment