我目前正在使用 YouTube API V2,但在收集视频描述时收到了不正确的数据。
这是我想得到的字符串
我们可以为所有伟大的目标达到 5000 个赞吗?:) http://www.facebook.com/GudjonDanielYT https://twitter.com/GudjonDaniel
但我得到了这个
GudjonDanielhttp://gdata.youtube.com/feeds/api/users/GudjonDanielkM0YirXKa4Lb7MsgqHWiMwEntertainmentgudjondaniel 我们能否为所有伟大目标获得 5000 个赞?:) http://www.facebook.com/GudjonDanielYT https://twitter.com/GudjonDaniel
我的代码,它在media:description
- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementname isEqualToString:@"title"] || [elementname isEqualToString:@"content"])
{
currentNodeContent = [[NSMutableString alloc] init];
}
else if ([elementname isEqualToString:@"entry"])
{
currentFeed = [ChanelFeeds alloc];
}
else if ([elementname isEqualToString:@"yt:duration"])
{
currentFeed.duration = [attributeDict objectForKey:@"seconds"];
}
else if ([elementname isEqualToString:@"yt:statistics"])
{
currentFeed.views = [attributeDict objectForKey:@"viewCount"];
}
else if ([elementname isEqualToString:@"gd:rating"])
{
currentFeed.rating = [attributeDict objectForKey:@"average"];
}
else if ([elementname isEqualToString:@"media:player"])
{
currentFeed.streamURL = [NSURL URLWithString:[attributeDict objectForKey:@"url"]];
}
else if ([elementname isEqualToString:@"media:thumbnail"] && !currentFeed.thumbnailURL)
{
currentFeed.thumbnailURL = [NSURL URLWithString:[attributeDict objectForKey:@"url"]];
}
}
- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementname isEqualToString:@"title"])
{
currentFeed.title = currentNodeContent;
currentNodeContent = nil;
}
else if ([elementname isEqualToString:@"media:description"])
{
currentFeed.description = currentNodeContent;
currentNodeContent = nil;
}
else if ([elementname isEqualToString:@"entry"])
{
[self.feeds addObject:currentFeed];
currentFeed = nil;
currentNodeContent = nil;
}
}