Glodenox / twitch-chat-monitor

Twitch Chat Monitor that allows the chat to be shown comfortably on a big monitor. Useful for room-scale streaming where the chat needs to be readable from a distance.
37 stars 9 forks source link

youtube chat integration #43

Open paul-lrr opened 11 months ago

paul-lrr commented 11 months ago

With Twitch relaxing their rules on simulcasting, we have been looking into the possibility of streaming to Youtube as well as Twitch. Not totally sure if/when it will happen (maybe just for "special events") but do you think it would be feasible to integrate the youtube chat into the monitor? Maybe with a small icon to indicate the source of the message.

Youtube appears to have it's own message API https://developers.google.com/youtube/v3/live/docs/liveChatMessages but I have no idea if it could be adapted to be compatible with what you are doing with Twitch

Glodenox commented 11 months ago

I've done some poking around, but the YouTube API seems to require either an app token or that the user signs in via OAuth. I'd have to check how either of those could be done without having to set a private key in the project. At first sight, this API also seems to only give access to the comments for the account that does the streaming. I can't immediately find a way to retrieve the chat ID for other channels. While that shouldn't be a blocker, it does mean that proper expectation management is needed in the configuration.

Before I look into those challenges, I'd have to work out how I would refactor the project to deal with multiple sources. I don't think it should be too complicated, as the addition of messages is already sufficiently decoupled from the graphical interface. But I'm more worried about how it would be displayed. Based on the experiences of Linus Tech Tips (who have a special agreement allowing them to simulcast), the chats can often have completely different conversations going. Just for that reason already, I think it would make most sense to at least support having layouts with separate chat windows instead of putting it all in the same window.

paul-lrr commented 11 months ago

Another factor with chat for Youtube streaming that I hadn't considered is that there isn't a persistent "youtube chat" for a channel in the same way as there is for twitch. Each stream is a new video entity with its own chat. That will probably make the chat monitor difficult and annoying to configure.

The concern about confusion arising from youtube and twitch chat having different conversations is also a good point. We might need to have some internal discussion about what we would prefer for that.

Glodenox commented 11 months ago

I had noticed that as well. If the authentication can be resolved (still need to check that), it is possible to retrieve the live videos for a channel and retrieve the liveChat reference for those videos. If there's only one live video, I think it could default to monitoring that video.

Slightly annoyingly, the API seems to require you retrieve all messages from the start, which seems very wasteful for a long-running or very active stream. Luckily, up to 2000 messages can be retrieved per call, so it shouldn't take too long.