2013-04-10 34 views
0

我能得到的只是片段變量...沒有統計數據相關。 我試圖得到每個特定視頻的喜歡,不喜歡和持續時間。使用GData Objective-C api ...有沒有辦法從YouTube獲取特定視頻的統計信息?

+(void) getListOfVideosFromSearchTerm: (NSString *) term usingCallback: (getListOfVideosCallback) callback{ 
    if (youTubeService.authorizer == nil) callback(nil); 
    __block NSMutableArray *videosArray = [NSMutableArray array]; 

    GTLQueryYouTube *query = [GTLQueryYouTube queryForSearchListWithPart:@"id,snippet"]; 
    query.maxResults = 10; 
    query.q = term; 
    query.videoEmbeddable = @"true"; 
    query.type = @"video"; 

    GTLServiceTicket *ticket = [youTubeService executeQuery:query 
            completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) { 
             // This callback block is run when the fetch completes 
             if (error == nil) { 
              GTLYouTubeSearchListResponse *products = object; 

              // iteration of items and subscript access to items. 
              for (GTLYouTubeSearchResult *item in products) { 
               ILVVideo *newVideo = [[ILVVideo alloc] init]; 
               newVideo.title = item.snippet.title; 
               newVideo.description = item.snippet.descriptionProperty; 
               newVideo.thumbnail.urlForHighResolution = item.snippet.thumbnails.high.url; 
               newVideo.thumbnail.highResolutionSize = CGSizeMake([item.snippet.thumbnails.high.width floatValue], [item.snippet.thumbnails.high.height floatValue]); 
               newVideo.thumbnail.urlForMediumResolution = item.snippet.thumbnails.medium.url; 
               newVideo.thumbnail.mediumResolutionSize = CGSizeMake([item.snippet.thumbnails.medium.width floatValue], [item.snippet.thumbnails.medium.height floatValue]); 
               newVideo.thumbnail.urlForStandardResolutionImage = item.snippet.thumbnails.standard.url; 
               newVideo.thumbnail.standardResolutionSize = CGSizeMake([item.snippet.thumbnails.standard.width floatValue], [item.snippet.thumbnails.standard.height floatValue]); 
               [videosArray addObject:newVideo]; 
               NSLog(@"%@",item.snippet.title); 

              } 
              callback(videosArray); 
             }else{ 
              NSLog(@"Error: %@", error.description); 
             } 
            }]; 

} 

回答

相關問題