问题
I am trying to keep track of the livestream viewers of a specific channel. This is no problem when I have got the stream ID and use it manually.
However I want my program to be able to track upcoming livestream automatically. So I want to get the livestream ID from the channel for the next upcoming livestream. I have been looking through the documentation from the API, but I couldn't find anything.
What API call do I need to make?
回答1:
You cannot get the liveBroadcast or liveStream object that does not belong to the user or channel you are authenticated as. The list
endpoint for each object requires your to authenticate as your own channel/user to retrieve your own live events only.
If you want to retrieve information on another channel's current live broadcasts, you have to use the standard Search/list endpoint:
part -> snippet
channelId
-> [channelId of the channel/user with the live event]
eventType -> live
type -> video
(required when setting eventType
to live
)
HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channelId}&eventType=live&type=video&key={YOUR_API_KEY}
来源:https://stackoverflow.com/questions/34904302/getting-livestreams-from-youtube-channel