Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding premieres through Youtube API

Premieres are a mix between a live stream and a traditional YouTube video. Detailed description: https://wersm.com/youtube-makes-premieres-available-to-everyone/

Is there any way for finding premieres of a channel through Youtube API?, is there any playlist, similar to autogenerated playlists of live broadcasts (https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig), only with premieres?

YouTube search:list end-point (https://developers.google.com/youtube/v3/docs/search/list) doesn't include a event type filter for this kind of video. Only includes "upcoming" and "live" event filters, but they don't work with premieres. Only work with live content.

Thanks in advance.

Best regards.

like image 413
Alberto Vicente López Avatar asked Nov 07 '22 11:11

Alberto Vicente López


1 Answers

The only way I have found is to:

  1. 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.

  2. 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.

  3. 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:

  1. 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.

  2. 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.

  1. Keep any videos that have a non zero duration.

That could work too.

like image 69
Alistair Jones Avatar answered Nov 16 '22 11:11

Alistair Jones