Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain a feed of comments entered through the 'chat' box during a YouTube live broadcast?

The YouTube API enables users to obtain a comments feed, e.g. via https://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments?orderby=published.

However, when I try to do just that with the video ID of a live stream, the result is always empty, no matter how many comments have been submitted. The only difference between a live video and any other video (or recording of a live stream) is that the 'comments' section is replaced with a 'chat' box, whose comments seem not to be available via the API.

When the stream is stopped, all comments submitted through the chat box 'disappear' entirely and can no longer be accessed. However, all comments submitted after the live broadcast has been archived (i.e. the recording has been made available) show up in the comments feed.

For a real-time application I need to access the 'chat' comments while the broadcast is still live, to retrieve user-submitted questions.

Is there any way to do this?

like image 417
Marcus Wernicke Avatar asked Oct 07 '14 06:10

Marcus Wernicke


People also ask

How do you see live chat comments on YouTube?

Accessing Comments Once you are live, tap the Live Comments tab (speech bubble icon) in the tab bar. As audience members comment, the comments will appear in chronological order, with new comments displaying at the bottom.

Do YouTube live chats get saved?

Live chat is turned on by default. After your live stream ends, it will be archived and viewers can replay the video along with the live chat.

How do I show comments on a live stream?

Once you have started your livestream, you can view incoming live comments. Tap the Live Comments tab (speech bubble icon) in the tab bar.

Why can't I see live comments on YouTube?

I Don't See Comments On My YouTube Live Replay, Where Did They Go? YouTube Live Chat can take up to 24 hours to appear on your YouTube Live videos. As long as your video is public when you stream it and you have Live Chat enabled on your channel, live comments will show up after YouTube has processed the video.


1 Answers

It is now possible to return chat messages for your own broadcasts using the LiveChatMessages endpoint as part of the YouTube Live Streaming API.

When creating a new liveBroadcast object, a liveChatId String will be returned as part of that liveBroadcast's snippet. Pass your broadcast's chat ID to LiveChatMessages/list endpoint's liveChatId parameter, and id, snippet, and authorDetails into the part parameter.

HTTP GET https://www.googleapis.com/youtube/v3/liveChat/messages?liveChatId={liveChatId}&part=id%2C+snippet%2C+authorDetails&key={YOUR_API_KEY}

This will return an array of liveChatMessage resources. The actual chat message is contained in the textMessageDetails dictionary as the value for the messageText key.

"textMessageDetails": {
  "messageText": string
}
like image 52
JAL Avatar answered Oct 20 '22 05:10

JAL