Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Setting part to snippet and contentDetails using the youtube api

$
0
0

I did some diggingandfound similar issues with the api. Im currently using the youtube-api to search for songs. I'm currently setting part to snippet which allows me to get the thumbnail and title. However with part set to snippet I cant get the length of the video or the channel who published the video image. Currently I'm trying to trying to get the video length, which I need part set to contentDetails. I tried something like this but it didn't work, what is the correct way to use them both togheter?

$(function(){$("#formen").on("submit",function(e){    e.preventDefault();     $("#result").html('');        var request = gapi.client.youtube.search.list({            order: "viewCount",            part: "snippet, contentDetails",            type: "video",               q: encodeURIComponent($("#search").val()).replace(/%20/g, "+"),             maxResults: 15        });    request.execute(function(response) {     console.log(response);        var results = response.result;         $.each(results.items, function(index, item) {             $.get("item.php", function(data) {                  $("#result").append(tplawesome(data, [{"title":item.snippet.title, "yturl":item.snippet.thumbnails.high.url, "videoid":item.id.videoId, "channelTitle":item.snippet.channelTitle}]));             });    });});});

});


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>