Guest User

Request YT Stream Wait Room v1

a guest
Jul 30th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. import requests as re
  2. from time import sleep
  3. from datetime import datetime
  4.  
  5. # %%
  6. # -- Config
  7. # url: Where the POST request is going to be made
  8. # REPLACE THE xxx WITH THE VALUE OF https://files.catbox.moe/vztrwo.png
  9. # It's a regular URL
  10. url = 'xxx'
  11.  
  12. # post_data: Body of the request (basically cookies)
  13. # REPLACE THE yyy WITH THE VALUE OF https://files.catbox.moe/yj02ac.png
  14. # It's a large blob of text
  15. post_data = 'yyy'
  16.  
  17. # -- Get session
  18. session = re.session()
  19.  
  20. # %%
  21. # -- Vars
  22. waiting = []
  23. timestamp = []
  24. n = 0
  25.  
  26. # -- Main loop
  27. # Makes the request 10 -1 times
  28. while (n := n + 1) < 10:
  29.     r = re.post(url, data=post_data)
  30.     ts = datetime.now()
  31.     data = r.json()
  32.     val = data['actions'][0]['updateViewershipAction']['viewCount']['videoViewCountRenderer']['viewCount']['simpleText']
  33.     val = val.split()
  34.     num = int(val[0].replace(',', ''))
  35.     print(n, num, ts, val[1])
  36.     # This makes it stop when YT no longer reports 'waiting', comment both lines if you don't want that
  37.     if val[1] != 'waiting':
  38.         break
  39.     waiting.append(val)
  40.     timestamp.append(ts.timestamp())
  41.     # Timer of 10 seconds, recommended more than 5
  42.     sleep(10)
Add Comment
Please, Sign In to add comment