Friday, 23 August 2013

Retrieving list of video information for an auto-generated YouTube playlist using v3 API

Retrieving list of video information for an auto-generated YouTube playlist using v3 API References // This is a first attempt at using YouTube\'s v3 API. It doesn\'t require authentication. getAutoGeneratedPlaylistData: function() { gapi.client.setApiKey(\'{API_KEY}\'); gapi.client.load(\'youtube\', \'v3\', function () { var request = gapi.client.youtube.playlistItems.list({ part: \'contentDetails\', maxResults: 50, playlistId: \'ALYL4kY05133rTMhTulSaXKj_Y6el9q0JH\', fields: \'items/contentDetails\' }); request.execute(function (response) { console.log(\"Response:\", response); }); }); } This code takes the playlistId of an auto-generated YouTube playlist and retrieves the first 50 items from it. The provided response\'s contentDetails contains each video\'s ID. It seems like if I want to retrieve all of the video information for an auto-generated playlist I will need to issue 2N requests to youtube? N requests to retrieve all of the video IDs from the playlist in sets of no more than 50. Once I have all of the video IDs... then I need to ask YouTube for video information for all of the videos. I can get data for 50 videos in one request... so that\'s another N requests to YouTube to retrieve all of the videos? This seems like a poor design decision. Previously, using v2 API, if I was retrieving all of the information for a playlist I could be sent all the necessary information for the videos in the initial request. Is this no longer possible using the V3 API? Am I supposed to incur O(2N) network costs...? Really?

No comments:

Post a Comment