alaouy / YouTube

🔥 Laravel PHP Facade/Wrapper for the Youtube Data API
MIT License
780 stars 205 forks source link

"getPlaylistItemsByPlaylistId" by date order #175

Closed benrolfe closed 2 years ago

benrolfe commented 2 years ago

Does anyone know how I can fetch the latest 5 videos from a YT playlist?

This is the PHP code I have so far:

$results = Youtube::getPlaylistItemsByPlaylistId('PLo00OmIdkKM1Frqs8ZExOWpDtXOPwG6Ng', '', 5)

But I don't know how to order by date.

alaouy commented 2 years ago

@benrolfe This is not supported on this method. It would be great if you can it to this package with a PR to provide this feature following the Youtube Data API: https://developers.google.com/youtube/v3/docs/search/list

Screenshot 2021-11-14 at 17 36 54

Let me know if you need help or have question

benrolfe commented 2 years ago

It looks like the endpoint in question (https://www.googleapis.com/youtube/v3/playlistItems) doesn't allow you to order.

https://developers.google.com/youtube/v3/docs/playlistItems/list

alaouy commented 2 years ago

@benrolfe So the only solution is that you load all the items and order them in memory.