Advertisement
Guest User

Untitled

a guest
Dec 31st, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. import datetime
  2. import hashlib
  3.  
  4.  
  5. def totimestamp(dt, epoch=datetime.datetime(1970,1,1)):
  6. td = dt - epoch
  7. # return td.total_seconds()
  8. return (td.microseconds + (td.seconds + td.days * 86400) * 10**6) / 10**6
  9.  
  10. streamername = input("Enter streamer name: ").strip()
  11. vodID = input("Enter vod id: ").strip()
  12. timestamp = input("Enter VOD timestamp (YYYY-MM-DD HH:MM:SS) UTC: ").strip()
  13.  
  14. year = int(timestamp[:4])
  15. month = int(timestamp[5:7])
  16. day = int(timestamp[8:10])
  17.  
  18. hour = int(timestamp[11:13])
  19. minute = int(timestamp[14:16])
  20. seconds = int(timestamp[17:])
  21.  
  22. td = datetime.datetime(year,month,day,hour,minute,seconds)
  23.  
  24.  
  25. converted_timestamp = totimestamp(td)
  26.  
  27. formattedstring = streamername + "_" + vodID + "_" + str(int(converted_timestamp))
  28.  
  29. hash = str(hashlib.sha1(formattedstring.encode('utf-8')).hexdigest())
  30.  
  31. requiredhash = hash[:20]
  32.  
  33. finalformattedstring = requiredhash + '_' + formattedstring
  34.  
  35. url = f"https://vod-secure.twitch.tv/{finalformattedstring}/chunked/index-dvr.m3u8"
  36.  
  37. print(url)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement