Hololive_STUFF

TerriblePythonSoFar

Feb 28th, 2021 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. import pytchat
  2. import time
  3. messagecount = 0
  4. SupaCount = 0
  5. ImportantMessageCount = 0
  6. start_time = time.time()
  7. #kcGhMnL2l2c #c7GwPw-72Ds #7-y8bVOb-cs #ipZOd9ESdlo
  8. vidID = input("Enter YoutubeID: ")
  9. OutputFile = open(vidID + ".txt", "a", encoding="utf8")
  10.  
  11. print(vidID)
  12. chat = pytchat.create(video_id=vidID)
  13. print(chat.is_alive())
  14. while not chat.is_alive():
  15. print("Chat not yet up!")
  16. time.sleep(15)
  17.  
  18. while chat.is_alive():
  19. #print(chat.get().json())
  20. #time.sleep(5)
  21. # Each chat item can also be output in JSON format.
  22. for c in chat.get().sync_items():
  23. messagecount += 1
  24. if c.type == "superChat" or c.type == "superSticker":
  25. SupaCount += 1
  26. print(f"{c.datetime}||{SupaCount}||{c.author.name}||{c.amountValue}||{c.currency}||{c.bgColor}||{c.message}")
  27. OutputFile.write(f"{c.datetime}||{SupaCount}||{c.author.name}||{c.amountValue}||{c.currency}||{c.bgColor}||{c.message}" + '\n')
  28.  
  29. #print(c.json())
  30. elif c.author.isChatOwner or c.author.isChatModerator:
  31. ImportantMessageCount += 1
  32. print(f"{c.datetime}||[{c.author.name}]||{c.message}")
  33. OutputFile.write(f"{c.datetime}||[{c.author.name}]||{c.message}" + '\n')
  34.  
  35. #if messagecount % 50 == 0:
  36. # print("--- %s seconds ---" % (time.time() - start_time))
  37.  
  38. print("--- %s seconds ---" % (time.time() - start_time))
  39. OutputFile.write("--- %s seconds ---" % (time.time() - start_time) + '\n')
  40. print(f"{messagecount} Messages, {SupaCount} SC, {ImportantMessageCount} Mod-Owner")
  41. OutputFile.write(f"{messagecount} Messages, {SupaCount} SC, {ImportantMessageCount} Mod-Owner" + '\n')
  42. OutputFile.close()
  43.  
  44. try:
  45. chat.raise_for_status()
  46. except pytchat.exceptions.ChatDataFinished:
  47. print("chat data finished")
  48. except Exception as e:
  49. print(type(e), str(e))
  50.  
  51.  
  52.  
  53.  
  54. ### don't judge me I don't know what the fuck I'm doing and haven't really finished and it's the ping my controller is broken
  55. #___________________________
  56.  
  57. import pytchat
  58. from pytchat import HTMLArchiver
  59. import time
  60. #seektime - set this negative to retrieve prechat
  61. messagecount = 0
  62. SupaCount = 0
  63. ImportantMessageCount = 0
  64. start_time = time.time()
  65. #chat = pytchat.create(video_id="Ww8HYMWdA3E",force_replay = True)
  66. #kcGhMnL2l2c -- Oblivion 4 #uV27ZN4bFsI #ITGeJV9xcZk -- Member Hangout 3/7 #Unph-P3vsfA -- Kiara Member Emote Draw -20/12/09 #16u2G57o6GE -- 6mo collab - Ame
  67.  
  68. vidID = input("Enter YoutubeID: ")
  69. OutputFile = open(vidID + ".txt", "a", encoding="utf8")
  70.  
  71. print(vidID)
  72. chat = pytchat.create(video_id=vidID,force_replay = True)
  73. while chat.is_alive():
  74. #print(chat.get().json())
  75. #time.sleep(5)
  76. # Each chat item can also be output in JSON format.
  77. #for c in chat.get().sync_items():
  78. for c in chat.get().items:
  79. messagecount += 1
  80. #time.sleep(0.1)
  81. if c.type == "superChat" or c.type == "superSticker":
  82. SupaCount += 1
  83. print(f"{c.datetime}||{SupaCount}||{c.author.name}||{c.amountValue}||{c.currency}||{c.bgColor}||{c.message}")
  84. OutputFile.write(f"{c.datetime}||{SupaCount}||{c.author.name}||{c.amountValue}||{c.currency}||{c.bgColor}||{c.message}" + '\n')
  85.  
  86. elif c.author.isChatOwner or c.author.isChatModerator:
  87. ImportantMessageCount += 1
  88. print(f"{c.datetime}||[{c.author.name}]||{c.message}")
  89. OutputFile.write(f"{c.datetime}||[{c.author.name}]||{c.message}" + '\n')
  90.  
  91. #if messagecount % 2000 == 0:
  92. #print("--- %s seconds --- processed %s messages ---" % (time.time() - start_time, messagecount))
  93.  
  94. print("--- %s seconds ---" % (time.time() - start_time))
  95. OutputFile.write("--- %s seconds ---" % (time.time() - start_time) + '\n')
  96. print(f"{messagecount} Messages, {SupaCount} SC, {ImportantMessageCount} Mod-Owner")
  97. OutputFile.write(f"{messagecount} Messages, {SupaCount} SC, {ImportantMessageCount} Mod-Owner" + '\n')
  98. OutputFile.close()
  99.  
  100. try:
  101. chat.raise_for_status()
  102. except pytchat.exceptions.ChatDataFinished:
  103. print("chat data finished")
  104. except Exception as e:
  105. print(type(e), str(e))
Add Comment
Please, Sign In to add comment