Guest User

Fishtank feeds to mpv bash script

a guest
Apr 26th, 2023
8,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.49 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. # USAGE
  14. # bash fishtank.sh
  15. # choose a number 1-10 after it asks you via feed >
  16. # press return
  17.  
  18. refresh_token=""
  19.  
  20.  
  21.  
  22.  
  23.  
  24. if [ -z "$refresh_token" ]
  25. then
  26.     echo "Add refresh_token"
  27.     exit
  28. fi
  29.  
  30. # use the new refresh_token instead of above
  31. if [ -f .refresh_token ]; then
  32.     refresh_token=$(cat .refresh_token)
  33. fi
  34.  
  35. # get your access and refresh tokens
  36. token_response=$(curl -s 'https://securetoken.googleapis.com/v1/token?key=AIzaSyBOOpV21k6o3cJc56-4uRNb0jDMzIxShMY' -X POST \
  37. --data-raw 'grant_type=refresh_token&refresh_token='$refresh_token'' --compressed)
  38. echo "$token_response" | jq -r '.access_token' > .access_token
  39. echo "$token_response" | jq -r '.refresh_token' > .refresh_token
  40.  
  41. get_feeds=$(curl -s 'https://www.fishtank.live/api/live-streams' \
  42. -H 'AuthToken: '$(cat .access_token)'' \
  43. --compressed | jq -r '.liveStreams | .[] | "\(.name)|\(.url)"')
  44.  
  45. while read -r line; do
  46.     feed_count=$[$feed_count +1]
  47.     echo -n "[$feed_count] "
  48.     echo "$line" | cut -d '|' -f1
  49. done <<< "$get_feeds"
  50.  
  51. read -r -ep "feed > " feed_choice
  52.  
  53. feed_token=$(sed -n ${feed_choice}p <<< "$get_feeds")
  54.  
  55. mpv --really-quiet --no-terminal "https://customer-jwh6wms36w6479b4.cloudflarestream.com/$feed_token/manifest/video.m3u8?parentOrigin=https%3A%2F%2Fwww.fishtank.live"
  56.  
Add Comment
Please, Sign In to add comment