【问题标题】:Pytchat is not fetching live chat from youtubePytchat 没有从 youtube 获取实时聊天
【发布时间】:2022-12-11 02:14:51
【问题描述】:
from pytchat import LiveChat
import time
chat = LiveChat(video_id = "uIx8l2xlYVY")

while chat.is_alive():
  try:
    data = chat.get()
    items = data.items
    for c in items:
        print(f"{c.datetime} [{c.author.name}]- {c.message}")
    time.sleep(3)
  except KeyboardInterrupt:
    chat.terminate()
    break

任何人都可以解释为什么即使多次更改视频 ID 也无法获取 YouTube 实时聊天。

【问题讨论】:

  • 什么错误。或者它正在输出什么以及您希望它输出什么?
  • 空白输出没有任何反应

标签: python


【解决方案1】:

这是修复:

import pytchat
import time
chat = pytchat.create(video_id="uIx8l2xlYVY")
while chat.is_alive():
  try:
    for c in chat.get().sync_items():
        print(f"{c.datetime} [{c.author.name}]- {c.message}")
    time.sleep(3)
  except KeyboardInterrupt:
    chat.terminate()
    break

希望这有帮助!

【讨论】:

  • 我尝试使用多个 ID……现在在 YouTube 上直播……没有任何反应。
  • 我想我发现了你的问题让我编辑我的回复。
  • 好吧我试试。。
  • 嘿,我再次编辑了我的答案,这应该是解决方法!
  • 仍然无法正常工作,无法获取 YouTube 实时聊天
【解决方案2】:

pytchat 不再维护,chat-downloader - 改用这个库,它可以工作

【讨论】:

    猜你喜欢
    • 2022-08-20
    • 2016-01-19
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 2018-11-05
    • 2022-12-10
    • 2021-08-16
    • 1970-01-01
    相关资源
    最近更新 更多