The only way I have found is to:
Use the search endpoint with a channel id filter to build a list of all the videos in a channel that have liveBroadcastContent
set to upcoming
. This will get you a list of all the premiere videos, as well as the livestreaming ones.
Use the search endpoint with a channel id filter and an eventType
filter for upcoming
. This will get you a list of all livestreaming ones.
Take the difference of the two set of ids.
I just tested and it works for my channel, but I'll admit it's quite expensive in terms of quota consumption. It's not a great answer, but it's the only answer. :)
Alternatively, if it's possible to impose some restrictions on your content uploader, then I would suggest that you either ask them to 1) add their a hash tag in their video description or 2) add the video to a special, public but non-listed playlist. That way your application can either search for that hash tag or read from that playlist, the latter being much much cheaper for quota consumption.
UPDATE
Another way to do it:
Use the search endpoint with a channel id filter to build a list of all the videos in a channel that have liveBroadcastContent
set to upcoming
. This will get you a list of all the premiere videos, as well as the livestreaming ones.
Use the video endpoint with the list of ids that you have gathered from above, and be sure to put the contentDetails
as part of the part
parameter. You can see the duration of the video here. It will resemble something like this
"contentDetails": {
"duration": "P0D",
"dimension": "2d",
"definition": "sd",
"caption": "false",
"licensedContent": false,
"contentRating": {},
"projection": "rectangular"
},
This video is definitely an upcoming livestream, because it has a zero duration P0D
. The upcoming premieres already have a fixed non-zero duration.
- Keep any videos that have a non zero duration.
That could work too.