15

I have made an RSS reader app in Xcode, which gets it's information from a YouTube channel. How can I get the thumbails from the videos?

I am able to use this link: http://gdata.youtube.com/feeds/mobile/users/HaatFilms/uploads?alt=rss

To get the uploads text, but what would I use to get the thumbnail for each specific video?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
RafeeJ
  • 441
  • 2
  • 6
  • 14

2 Answers2

18

Using the listed RSS feed:

You'll see links that include:

LKk6SvGmJj4

Previous episode: http://youtu.be/LKk6SvGmJj4 http://gdata.youtube.com/feeds/mobile/videos/LKk6SvGmJj4

That's the youtube ID.

Take that ID and use it with a straight image tag.

http://img.youtube.com/vi/LKk6SvGmJj4/0.jpg
http://img.youtube.com/vi/LKk6SvGmJj4/1.jpg

Use those images to populate your tables. Personally, I use Afnetworking's UIImageView category.

https://github.com/AFNetworking/AFNetworking

 UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)];
 [imageView setImageWithURL:[NSURL URLWithString:@"http://img.youtube.com/vi/LKk6SvGmJj4/1.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]];
warpedspeed
  • 1,098
  • 11
  • 28
5

I have used UIImageView+AFNetworking category to load image to an UIImageView. UIImageView+AFNetworking

NSString * youtubeID = @"TJkmc8-eyvE";
NSURL *youtubeURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://img.youtube.com/vi/%@/0.jpg",youtubeId];

[imageView setImageWithURL:youtubeURL] placeholderImage:[UIImage imageNamed:@"placeHolderImage"]];
Ayush
  • 3,989
  • 1
  • 26
  • 34
  • Sorry, I have been busy, When I Tried it.. It didn't work. Am I supposed to add something else other than the stated code above? – RafeeJ Sep 15 '13 at 14:56
  • yeah you need to add afnetworking to load images asynchronous in you app. What error you are getting – Ayush Sep 15 '13 at 15:05