1

I parsed the "url_encoded_fmt_stream_map=" entries with the direct video urls of some formats, example (decoded):

http://r7---sn-2apm-f5f6.c.youtube.com/videoplayback?gcr=de&cp=U0hUTFVUUl9LUENONF9NTlZHOkpGR0NWdWtvSk15&source=youtube&ip=46.59.194.67&upn=KHmKgXE5di4&fexp=917000,906357,911115,916611,920704,912806,928001,922403,922405,929901,913605,929104,913546,913556,908496,920201,913302,919009,911116,901451,902556&ms=au&itag=45&mt=1357571596&sparams=cp,gcr,id,ip,ipbits,itag,ratebypass,source,upn,expire&id=e4b675c403014739&expire=1357594666&ipbits=8&mv=m&newshard=yes&ratebypass=yes&sver=3&key=yt1&signature=1C8204D1180CAB0B57E3B3331409BD055CBA25B1.73FBEC95E020BBCAC6485D62601E8CF05ACA72DE,quality=hd720&itag=22&fallback_host=tc.v23.cache2.c.youtube.com&type=video/mp4;+codecs="avc1.64001F,+mp4a.40.2"

But I can't download or view it! VLC says: Cannot open! Firefox remains empty (white window, no error message)! Are the urls after "url_encoded_fmt_stream_map=" right?

4

1 回答 1

0

在我的回答 https://stackoverflow.com/a/14352995/307547 中,我描述了下载 youtube 视频的解决方案。

LBYouTubeExtractor *extractor = [[[LBYouTubeExtractor alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:(@"http://www.youtube.com/watch?v=%@"), self.videoID ]] quality:LBYouTubeVideoQualityLarge] autorelease];
[extractor extractVideoURLWithCompletionBlock:^(NSURL *videoURL, NSError *error) {
    if(!error) {
        NSLog(@"Did extract video URL using completion block: %@", videoURL);

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSData *data = [NSData dataWithContentsOfURL: videoURL];
            NSString *pathToDocs = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
            NSString *filename = [NSString stringWithFormat:(@"video_%@.mp4"), self.videoID ];
            [data writeToFile:[pathTODocs stringByAppendingPathComponent:filename] atomically:YES];
            NSLog(@"File %@ successfully saved", filename);
        });
    } else {
        NSLog(@"Failed extracting video URL using block due to error:%@", error);
    }
}];

您可以使用上述帖子中描述的技术显示下载进度。您可以将 dataWithContentsOfURL 替换为更适合您的方法。

于 2013-01-16T07:10:33.963 回答