Sorting Youtube API result from playlist

后端 未结 4 832
后悔当初
后悔当初 2021-01-04 07:40

I have been struggling with Youtube\'s API v3 now and I can\'t get it work in the way I want. My goal is to load the latest videos from a selected playlist into my website.

4条回答
  •  礼貌的吻别
    2021-01-04 08:01

    This does seem to be a limitation currently of the YouTube API and seems quite short-sighted by its creators.

    This doesn't solve your exact problem, but for others having a similar problem, I found that using the 'search' query you can order to a certain extent.

    This helped me order a playlist (not playlistItems) query by searching for playlists rather than requesting a list of playlists. Thus my query:

    https://www.googleapis.com/youtube/v3/playlists?part=snippet&maxResults=20&channelId={channelID}&key={API_KEY}
    

    became:

    https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&order=date&safeSearch=none&maxResults=20&channelId={channelID}&key={API_KEY}
    

    You can also search for videos and query terms and several other parameters, so maybe you can get the results you want this way.

提交回复
热议问题