title: Get video duration (contentDetails) with Youtube JavaScript API v3
body: <p>I've been trying to get a video duration with Youtube JavaScript API v3, this is the relevant part of my JS:</p>
  
  <pre><code>var request = gapi.client.youtube.search.list({
              q: 'eminem',
              part: 'snippet'
      });
  
      request.execute(function(response)  {                                                                                    
          $('#results').empty()
          var srchItems = response.result.items;     
  
          $.each(srchItems, function(index, item) {
              vidTitle = item.snippet.title;
              vidTime = item.contentDetails.duration;
              vidThumburl =  item.snippet.thumbnails.default.url;               
              $('#results').append('&lt;pre&gt;' + vidTitle + vidTime +'&lt;/pre&gt;');                      
          });  
      });
  </code></pre>
  
  <p>The problem is in <code>vidTime = item.contentDetails.duration;</code> and console returns the following error: </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'duration' of undefined</p>
  </blockquote>
  
  <p>But, i'm looking the JSON structure returned in the request (<a href="https://developers.google.com/youtube/v3/docs/videos" rel="nofollow">See Here</a>) and it was to be working, and I don't know why i'm getting this error :(</p>
  
  <p>I've tried to change the <code>part</code> to: <code>part: snippet, contentDetails</code> but with this change i've more errors...</p>
  
  <p>So, how to do to fix this?</p>
  
  <p><strong>EDITED</strong></p>
  
  <p>To analyze the return of <code>console.log(response);</code> I could see that the contentDetails is not returned in the array, but then how can I get the video duration?</p>