Christien
Christien

Reputation: 1213

how to get YouTube Video URL

I am looking for Youtube Downloader app .and to download Video Firstly I need to get the URL of the Running video.How do I get the url of the video which i play.

but when I play any video into the simulator it automatically gives me some information of the url..which is

2013-02-21 12:25:26.518 MyTube[682:14003] [MPAVController] Autoplay: Enabling autoplay
2013-02-21 12:25:26.518 MyTube[682:14003] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2013-02-21 12:25:26.518 MyTube[682:14003] setting movie path: http://r19---sn-a5m7lner.c.youtube.com/videoplayback?mt=1361429411&ipbits=8&fexp=919113%2C927902%2C916716%2C916612%2C901447%2C902545%2C920704%2C912806%2C902000%2C922403%2C922405%2C929901%2C913605%2C925006%2C906938%2C931202%2C908529%2C920201%2C930101%2C926403%2C901451&newshard=yes&key=yt1&signature=2AB1FC44B4EDA0C5DDF4E715FDCA19FFB16E0FF7.732382C58B3C8CBC4840D462940DFE2FEC9FBE53&source=youtube&sver=3&mv=m&expire=1361452937&ms=au&itag=36&el=watch&dnc=1&cp=U0hVRlRQUF9IUUNONV9MSlRKOjVNc1BwWTUxSVR2&upn=r3oQUqMCths&sparams=cp%2Cid%2Cip%2Cipbits%2Citag%2Cratebypass%2Csource%2Cupn%2Cexpire&ip=117.215.128.101&app=youtube_mobile&ratebypass=yes&yms=0PtNsY21DUs&id=2a147a30c3da7601

that means setting movie path url which I needed ..but it comes automatically in the output ..do can i fetch this url ...so that I can download

I am just Playing youtube video into the Webview

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.youtube.com"]]];

Upvotes: 1

Views: 8679

Answers (3)

etayluz
etayluz

Reputation: 16416

You can use HCYoutubeParser: https://github.com/hellozimi/HCYoutubeParser

NSString *videoUrl = [NSString stringWithFormat:@"https://www.youtube.com/watch?v=%@", videoId];
NSDictionary *videos = [HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:videoUrl]];
videoUrl = videos[@"small"];

Upvotes: 0

Alexander
Alexander

Reputation: 7238

Youtube is a little bit tricky in iOS because it's doesn't provide the real video link that obvisioulsy. There is a good plugin clalled LBYoutubeView which handles to extract the real url for you. You can have a look at the link extractor if you just want to download the video...

Another opportunity is to use the gdata objective c client and and import the extracted link in an UIWebView. But keep in mind that the gdata client doesn't provide you with the real link like the framework above.

And be aware, that UIWebivews in simulators < 6.0 probably do not support playing a youtube video in a UIWebview.

At least here is an example of how to embed a youtube video directly in an UIWebView:

[self.webView loadRequest:[NSURLRequest requestWithURL:
                           [NSURL URLWithString:
                            [NSString stringWithFormat:@"%@%@", @"http://www.youtube.com/embed/", @"THEYOUTUBEID"]]]];

Upvotes: 1

Daniel Kl&#246;ck
Daniel Kl&#246;ck

Reputation: 21137

You can use the YouTube API to fetch the URL. Take a look here and here

Upvotes: 2

Related Questions