Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i decrypt signature and add to the YouTube Extracted URL in objective c?

I am trying to play youtube video in my application. everything works fine. but when i am trying to watch video that contains content from youtube. it fails.

I researched found one think that you should encrypt and decrypt signature and add this to the URL?

I dont know how to decrypt signature in IOS?

http://www.youtube.com/get_video_info?video_id=uuZE_IRwLNI&el=vevo&ps=default&eurl=&gl=US&hl=en

stream

 {
    "fallback_host" = "tc.v12.cache7.googlevideo.com";
    itag = 22;
    quality = hd720;
    s = "8E6E5D13EB65FB653B173B94CB0BCC3A20853F5EDE8.5E2E87DF33EEDE165FEA90109D3C7D5DADA06B6BB60";
    type = "video/mp4; codecs=\"avc1.64001F, mp4a.40.2\"";
    url = "http://r7---sn-cvh7zn7r.googlevideo.com/videoplayback?pcm2fr=yes&sver=3&expire=1393773646&itag=22&id=bae644fc84702cd2&upn=SjZd81MudQs&sparams=gcr%2Cid%2Cip%2Cipbits%2Citag%2Cpcm2fr%2Cratebypass%2Csource%2Cupn%2Cexpire&ms=au&gcr=in&mt=1393747698&source=youtube&ratebypass=yes&ipbits=0&fexp=935620%2C919120%2C912523%2C932288%2C914084%2C916626%2C937417%2C937416%2C913434%2C932289%2C936910%2C936913%2C902907&mv=m&key=yt5&ip=103.250.162.79";
}

When i use url its not playing. is there any solution?

like image 705
Sunny Shah Avatar asked Mar 05 '14 04:03

Sunny Shah


2 Answers

You can't just use get_video_info data alone, you also need to download the main video page in order to see which html5player-XXXXX.js javascript file is loaded. This will dictate which permutations are needed. See http://www.jwz.org/hacks/youtubedown (written in Perl) as an example -- skip to the section that says "This is not crypto or a hash, just a character-rearrangement cipher. Total security through obscurity. Total dick move.", which is a sentiment I heartily concur with.

like image 131
Stuart Caie Avatar answered Oct 06 '22 00:10

Stuart Caie


The XCDYouTubeKit library does this with a very simple API for you to use.

NSString *videoIdentifier = @"uuZE_IRwLNI";
[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) {
    if (video)
    {
        // All URLs, with decrypted signature, are available in the `video.streamURLs` dictionary
    }
    else
    {
        // Handle error
    }
}];

Disclaimer: I’m the author of XCDYouTubeKit.

like image 25
0xced Avatar answered Oct 06 '22 01:10

0xced