Reputation: 1802
I try to receive a full list of videos which are part of the preferred category and I have a problem with it. First of all I check categories doing it:
func getCategories(complishion: ([CategoriesTitle]) -> Void ){
let youTubeURLCategoriesAdress = "https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode=US&key=\(YOUTUBE_ACCESS_KEY)"
Alamofire.request(.GET, youTubeURLCategoriesAdress).responseJSON(completionHandler: { (response: Response<AnyObject, NSError>) in
switch response.result {
case .Success:
if let json = response.result.value{
if let items = json["items"]{
print(items)
guard let categories: Array<CategoriesTitle> = Mapper<CategoriesTitle>().mapArray(items) else {
return
}
dispatch_async(dispatch_get_main_queue(), {
categoriesTitles(categories)
})
}
}
}
in this case I receive all results. One example bellow:
etag = "\"5g01s4-wS2b4VpScndqCYc5Y-8k/nqRIq97-xe5XRZTxbknKFVe5Lmg\"";
id = 10;
kind = "youtube#videoCategory";
snippet = {
assignable = 1;
channelId = "UCBR8-60-B28hp2BmDPdntcQ";
title = Music;
};
and then I don't know how should I send request to the YT API and ask about full list of videos which are part of category 'Music' with id = 10 in this case. Any ideas?
Upvotes: 0
Views: 1772
Reputation: 706
The request below returns all videos within the Category "10" - you need to set the type
to video
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&videoCategoryId=10&key=
{YOUR_API_KEY}
Upvotes: 1