ios - downloading video from youtube objective c -
i'm trying download video youtube getting error.
error mention in code
my code
-(void)downloadvideo{ lbyoutubeextractor *extractor = [[lbyoutubeextractor alloc] initwithurl:[nsurl urlwithstring:[nsstring stringwithformat:(@"https://www.youtube.com/watch?v=%@"), videoidtodownload ]] quality:lbyoutubevideoqualitylarge]; [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), ^{ nserror* error = nil; nsdata* data1 = [nsdata datawithcontentsofurl:videourl options:nsdatareadinguncached error:&error]; //data1 nill if (error) { //error domain=nscocoaerrordomain code=256 "the file “3gpp;+codecs="mp4v.20.3,+mp4a.40.2"&fallback_host=tc.v8.cache4.googlevideo.com&itag=36” couldn’t opened." nslog(@"error=%@", error); }else{ nsstring *filename = [nsstring stringwithformat:(@"video_%@.mp4"), videoidtodownload ]; [data1 writetofile:[dirpath stringbyappendingpathcomponent:filename] atomically:yes]; nslog(@"file %@ saved", filename); } }); } else { nslog(@"failed extracting video url using block due error:%@", error); } }];
}
using lib https://github.com/larcus94/lbyoutubeview
if solution please me.
thanks
Comments
Post a Comment