detecting youtube video links programmatically in Objective-C
This will grab the video ids if you are consistently expecting they to be in the < object > format. Regex will obviously need to be changed if it's in an iframe.
NSError *error = nil;
NSRegularExpression *regex =
[NSRegularExpression regularExpressionWithPattern:@"<object .*name=\"movie\" value=\"[a-zA-z:\\/]*.com\\/\\w*\\/([A-Za-z0-9\\_-]*).*<\\/object>"
options:NSRegularExpressionCaseInsensitive
error:&error];
[regex enumerateMatchesInString:pageSource options:0 range:NSMakeRange(0, [string length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop){
NSString *videoID = [pageSource substringWithRange:[match rangeAtIndex:1]];
}];
You can save downloaded videos either to photos album or to the app directory itself.For downloading videos u have to generate a downloadble link of the corresponding video.In the case of downloading videos from the site youtube,refer this source code https://github.com/comonitos/youtube_video. Some sites are download restricted ones that may not be possible.In the case of all other sites by generating the downloadable url,you can make it work