получить элементы с помощью API YouTube на цель C - PullRequest
0 голосов
/ 18 февраля 2011

Я просмотрел документацию, использовал пример проекта и даже получил извлечение фида YouTube, работающего в моем приложении, но я не могу получить отдельные элементы, которые затем отображаются по желанию.

IЯ могу получить, например, первое видео, используя objectAtIndex: 0, но потом не знаю, как получить заголовок, идентификатор, URL и т. д. Вот NSLog моего первого видео в ленте.

entry: GDataEntryYouTubeVideo 0x9eb8d50: {v:2.0 title:Evolution of Dance - By Judson Laipply contentSrc:http://www.youtube.com/v/dMH0bHeiRNg?f=standard&d=AVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata etag:W/"A0cHQ347eCp7ImA9Wx9UGUo." authors:1 categories:4 links:alternate,video.responses,video.ratings,video.complaints,video.related,self id:tag:youtube.com,2008:video:dMH0bHeiRNg rating:+706815/-62385 comment:GDataComment 0x9ebeb50: {feedLink:GDataFeedLink 0x9ebf2c0: {href:http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments countHint:500786 href:http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments countHint:500786}} stats:GDataYouTubeStatistics 0x9ebfeb0: {viewCount:164922648 favoriteCount:1010039} mediaGroup:GDataYouTubeMediaGroup 0x9ec0e10: {categories:(
    "GDataMediaCategory 0x9ec41f0: {label:Comedy scheme:http://gdata.youtube.com/schemas/2007/categories.cat content:Comedy}"
) contents:(
    "GDataMediaContent 0x9ec2df0: {url:http://www.youtube.com/v/dMH0bHeiRNg?f=standard&d=AVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata type:application/x-shockwave-flash medium:video isDefault:true expression:full duration:360}",
    "GDataMediaContent 0x9ec3620: {url:rtsp://v5.cache7.c.youtube.com/CkcLENy73wIaPgnYRKJ3bPTBdBMYDSANFEgGUghzdGFuZGFyZHIhAVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDmDA==/0/0/0/video.3gp type:video/3gpp medium:video expression:full duration:360}",
    "GDataMediaContent 0x9ec39b0: {url:rtsp://v3.cache8.c.youtube.com/CkcLENy73wIaPgnYRKJ3bPTBdBMYESARFEgGUghzdGFuZGFyZHIhAVEzC5trXMDfhc6PnAqxlmIO88HsQjpE1a8d1GxQnGDmDA==/0/0/0/video.3gp type:video/3gpp medium:video expression:full duration:360}"
) credits:(
    "GDataMediaCredit 0x9ec4730: {role:uploader scheme:urn:youtube content:judsonlaipply}"
) thumbnails:(
    "GDataMediaThumbnail 0x9ec4fb0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/default.jpg height:90 width:120 time:00:03:00 unparsedAttr:yt:name}",
    "GDataMediaThumbnail 0x9ec5820: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/hqdefault.jpg height:360 width:480 unparsedAttr:yt:name}",
    "GDataMediaThumbnail 0x9ec5bc0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/1.jpg height:90 width:120 time:00:01:30 unparsedAttr:yt:name}",
    "GDataMediaThumbnail 0x9ec5ea0: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/2.jpg height:90 width:120 time:00:03:00 unparsedAttr:yt:name}",
    "GDataMediaThumbnail 0x9ec6140: {url:http://i.ytimg.com/vi/dMH0bHeiRNg/3.jpg height:90 width:120 time:00:04:30 unparsedAttr:yt:name}"
) keywords:GDataMediaKeywords 0x9ec66f0: {content:Dancing, comedy keywords:Dancing, comedy} description:GDataMediaDescription 0x9ec4e10: {type:plain content:For more visit http://www.mightaswelldance.com} players:(
    "GDataMediaPlayer 0x9ec2e40: {url:http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata_player}"
) title:GDataMediaTitle 0x9ec6aa0: {type:plain content:Evolution of Dance - By Judson Laipply} duration:360 videoID:dMH0bHeiRNg uploaded:GDataDateTime 0x7359b80: {2006-04-06T21:30:53Z}} accessControls:(
    "GDataYouTubeAccessControl 0x9ec0500: {action:comment permission:allowed content:}",
    "GDataYouTubeAccessControl 0x9ec0930: {action:commentVote permission:allowed content:}",
    "GDataYouTubeAccessControl 0x9ec09f0: {action:videoRespond permission:moderated content:}",
    "GDataYouTubeAccessControl 0x9ebeba0: {action:rate permission:allowed content:}",
    "GDataYouTubeAccessControl 0x9ebf9f0: {action:embed permission:allowed content:}",
    "GDataYouTubeAccessControl 0x9ec0620: {action:list permission:allowed content:}",
    "GDataYouTubeAccessControl 0x9ec0b50: {action:syndicate permission:allowed content:}"
) unparsed:<gd:rating>}

1 Ответ

1 голос
/ 18 февраля 2011

решено, сравните вызовы с xml выше, чтобы вы могли использовать их в других каналах gdata

GDataEntryBase *entry = [[feed entries] objectAtIndex:indexPath.row];
        NSString *title = [[entry title] stringValue];
        NSArray *thumbnails = [[(GDataEntryYouTubeVideo *)entry mediaGroup] mediaThumbnails];

        cell.textLabel.text = title;

        NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[thumbnails objectAtIndex:0] URLString]]];
        cell.imageView.image = [UIImage imageWithData:data];
...