0

I'm using the YouTube Data API to fetch a list of videos for some of my favourite channels. Functionally, it's all working great but I am hitting the daily quota now that the list of channels I am interested in has grown.

I currently do this (pseudo code):

foreach( channelId in myListOfChannelIds){

  YouTubeService.Search.List("snippet")
    .ChannelId = channelId
    .Type = "video"
    .MaxResults = 10
    .Order = SearchResource.ListRequest.OrderEnum.Date

  searchListResponse = await searchListRequest.ExecuteAsync();

  foreach( item in searchListResponse.Items ) {

    <process the item>
  }
}

This is fine; I get the most recent 10 videos for each of my channels.

What I think I would like to do is:

  • For each Channel, establish the date of the last video
  • For every channel that has a recent video in the past 'n' days, fetch the most recent 10 videos (as per the code above)

I can't see anything on the API for finding the last published date for a channel and the channel list doesn't appear to have summary metadata exposed.

Does anyone have any pointers in case I have missed something or can suggest a better way to achieve my objective? it seems the channel list is an expensive (in units) operation.

Thanks in advance

(I'm using C#)

  • This is what you are looking for: https://stackoverflow.com/a/22616491/7123660 – Benjamin Loison Mar 26 '22 at 10:59
  • Unless I am mistaken, it doesn't have a time element that indicates the last post date/time for a channel – AlanTwoRings Mar 26 '22 at 11:35
  • The [PlaylistItems: list](https://developers.google.com/youtube/v3/docs/playlistItems/list) endpoint by default lists videos from the most recent one to the oldest one. If you really look for a date (even if [optimizing performance](https://developers.google.com/youtube/v3/getting-started#performance) isn't enough) then you can still use [Videos: list](https://developers.google.com/youtube/v3/docs/videos/list) with `part=snippet` which will give you a `publishedAt` field. – Benjamin Loison Mar 26 '22 at 18:46

1 Answers1

0

Since you have the channel_id, you can save quota by follow these steps:

  1. Change the second letter of the channel_id to "U".

Example:

Channel_id: UCYzHwra_yDr-QGFiopiOPnw, change it to: UUYzHwra_yDr-QGFiopiOPnw

The changed channel_id is the "uploads" playlist of the given channel.

  1. Then, use this endpoint instead:

https://www.youtube.com/feeds/videos.xml?playlist_id=<UPLOADS_PLAYLIST_ID>

Example:

https://www.youtube.com/feeds/videos.xml?playlist_id=UUYzHwra_yDr-QGFiopiOPnw

You will see there the recent 15 videos uploaded by that channel and each entry has the info you need.