I am using this to get the information of the video such title and image.
var urlString = "https://www.googleapis.com/youtube/v3/search?part=snippet&fields=items(id,snippet(title,channelTitle,thumbnails))&order=viewCount&q=\(text)&type=video&maxResults=25&key=\(apiKey)"
This above URL will return a JSON.
["items": <__NSArrayI 0x1c41b03e0>(
{
id = {
kind = "youtube#video";
videoId = n3T3K2MHNjM;
};
snippet = {
channelTitle = "Ty Dolla $ign";
thumbnails = {
default = {
height = 90;
url = "https://i.ytimg.com/vi/n3T3K2MHNjM/default.jpg";
width = 120;
};
high = {
height = 360;
url = "https://i.ytimg.com/vi/n3T3K2MHNjM/hqdefault.jpg";
width = 480;
};
medium = {
height = 180;
url = "https://i.ytimg.com/vi/n3T3K2MHNjM/mqdefault.jpg";
width = 320;
};
};
title = "Ty Dolla $ign & Future - Darkside feat. Kiiara (from Bright: The Album) [Official Audio]";
};
},
but there is no content details in the JSON I would like to access the content details since its contains the duration of the video which i needed. I had try to access with url like this by inserting the contentDetails into the URL but it is not working.
var urlString = "https://www.googleapis.com/youtube/v3/search?part=snippet&fields=items(id,contentDetails,snippet(title,channelTitle,thumbnails))&order=viewCount&q=\(text)&type=video&maxResults=25&key=\(apiKey)"
How can i retrieve the content details also ?