У меня возникли проблемы с получением видеоролика для видео YouTube. Я могу получить элементы плейлиста с эскизом и заголовком, но я не могу получить фактический видеоролик.URL-адрес YouTube Objective-C API из плейлиста
GTLServiceYouTube *service = [[GTLServiceYouTube alloc] init];
service.APIKey = @"API Key";
GTLQueryYouTube *query = [GTLQueryYouTube queryForPlaylistItemsListWithPart:@"snippet,contentDetails"];
query.playlistId = @"playlist ID";
query.maxResults = 50;
GTLServiceTicket *ticket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
// This callback block is run when the fetch completes
if (error == nil)
{
GTLYouTubeSearchListResponse *products = object;
for (GTLYouTubeSearchResult *item in products)
{
NSLog(@"%@", item.snippet);
NSString *dictionary = [item.snippet JSONValueForKey:@"videoId"];
GTLYouTubeThumbnailDetails *thumbnails = item.snippet.thumbnails;
GTLYouTubeThumbnail *thumbnail = thumbnails.high;
NSString *thumbnailString = thumbnail.url;
if (thumbnailString != nil)
{
[self.thumbnailsArray addObject:thumbnailString];
[self.thumbnailTitleArray addObject:item.snippet.title];
//[self.videos addObject:video];
NSLog(@"id: %@", dictionary);
}
}
}
else
{
NSLog(@"Error: %@", error.description);
}
[self.tableView reloadData];
}];
Кто-нибудь знает, как получить видеоролик с помощью API YouTube?
Работал отлично! Мне просто нужно было изменить item.id.videoId на item.identifier.videoId. Спасибо за ваш ответ! : D –