YouTube API "orderby = duration" does not process the entire playlist, but only the latest videos

I am trying to create a small JavaScript program to request a YouTube API for a specific playlist, sorted by duration. Everything works fine, but the order does not take into account the entire playlist, only 25 new videos! Here is a minimal complete working example like JSFiddle and here is part of JavaScript:

var playlistId = "UUAuUUnT6oDeKwE6v1NGQxug"; jQuery.getJSON( "https://gdata.youtube.com/feeds/api/playlists/"+playlistId+"?v=2&orderby=duration&alt=json", function(data) { $.each(data.feed.entry, function(key, val) { var title = val.title.$t; var url = val.content.src; var duration = val.media$group.yt$duration.seconds; var minutes = Math.floor(duration / 60); var seconds = (duration % 60); if( seconds < 10 ) seconds = "0"+seconds; var newRow = $("<tr></tr>"); newRow.append("<td><a href='"+url+"'>"+title+"</a></td>"); newRow.append("<td class='dur'>"+minutes+":"+seconds+"</td>"); $("#videos").append(newRow); }); } ); 

I tried this in both XML and JSON, and I also tried other kinds of searches besides playlist searches. With the API sorting, only the newest result videos seem completely pointless. How can I get the longest or shortest videos from a playlist or those uploaded by a given user?

+7
source share
1 answer

EDIT

I do not think that the functionality you want is available. Ordering by duration is not even available on YouTube itself. I think you will need to use max-results and start-index to extract blocks of video. Then you can sort the compiled list by duration.

Here is a working example of one possible solution: http://jsfiddle.net/PKcnb/8


I found where Google says this explanation is impossible.

YouTube API v2.0 - Video Stream Types: Videos Uploaded by a Specific User

This section explains how to get a feed containing all the video uploaded by a specific user. You should not include search parameters in requests for retrieving a downloaded video . the parameters will generate a feed from the YouTube search index, effectively limiting the result set to indexed, public videos, rather than returning a complete list of videos uploaded by the user.

The following is said:

To request a channel for all videos currently downloaded by the user, send a GET request to the following URL. This request requires an authentication token that allows YouTube to authenticate the user.

So it is possible, but you will have to test it with an authentication token.


Original publication

+6
source

All Articles