1

I need to get daily uploaded videos in a playlist so thought to get videos for a playlist sorted by published date. So is there any option to pass published date while fetching data for playlist?

I tried 2 options

option 1 ) https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=15&playlistId=PLP-nGFpz3fa_boeLhG4m0Ie_8vmCvp5oH&key={YOUTUBE_API_KEY}

does result return from this URL is in sorted order? I found its not in sorted order. Can I pass some date parameters related to date in this or some sort related parameters?

option2 ) I tried using "Youtube Search API" https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list

here we have date option but only can pass channelId not playlistId. So can we pass playlistId in search API to get all videos for playlist?

Is there any other way which I can use?

Thanks

2 Answers2

1

The PlaylistItems:list does not have any way to order results - the playlist order is returned in the order specified by the owner. Nor does Search:list allow you to specify a playlist.

Does the playlist owner add new videos to the beginning or end of the playlist? If the beginning, you could try fetching the first X videos and comparing the publish date to the current date.

johnh10
  • 4,047
  • 1
  • 18
  • 30
  • we want to make it generic(for any playlist on youtube) so really can not depend on playlist owner...if owner add it to beginning the logic will work but what about if owner add it in last, we will end up fetching all videos in playlist to get latest videos... – ankit varshney Oct 22 '16 at 14:38
0

Looking at the guide using Videos.list, nowhere does it mention that this feature is available, where the list is readily sorted upon return of the response body. Try putting the results in a container first where you will implement your own comparison of dates to sort the items. This SO thread seems to confirm this.

Community
  • 1
  • 1
ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
  • If we will use our own container for comparison we may end up getting all videos of playlist to fetch the latest added videos.(may be latest added videos are last in result)....so if we have 50000 videos in playlist and only 2 are added for a particular date ,we may need to fetch all 50000 videos to get those 2 newly added videos... :( – ankit varshney Oct 22 '16 at 14:41
  • It's not supported at this moment. Maybe you can start on this project or file a feature request. – ReyAnthonyRenacia Oct 22 '16 at 15:10