Reputation: 23
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
Upvotes: 1
Views: 3800
Reputation: 17613
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.
Upvotes: 0
Reputation: 4185
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.
Upvotes: 1