问题
I am building a webpage to display the live streaming status of several YouTube channels which I do not manage. The page will display a list of selected channels, with a ● red dot beside any channel which is live streaming right now. I also want the webpage to update that status in realtime, so if a channel begins live streaming, I need to immediately add the dot, and when a channel stops live streaming, I need to immediately remove the dot.
I can use the Data API to:
- find upcoming events on a channel, using the
searchendpoint with achannelId,type=videoandeventType=upcoming - retrieve the
scheduledStartTimeof an upcoming event, using thevideosendpoint withpart=liveStreamingDetails - find live events on a channel, using the
searchendpoint with achannelId,type=videoandeventType=live - retrieve the
actualStartTimeof a live event, using thevideosendpoint withpart=liveStreamingDetails - retrieve the
actualEndTimeof a completed event, using thevideosendpoint withpart=liveStreamingDetails
I would really like to avoid polling the videos endpoint to monitor the status of live streams. Can I subscribe to a set of channel IDs or video IDs, to receive a message in real time when:
- when an upcoming event actually starts live streaming
- when a live stream is completed/terminated
- for channels which I don't manage?
Is this possible?
来源:https://stackoverflow.com/questions/61051899/getting-realtime-information-about-live-streaming-on-youtube