【发布时间】:2012-08-02 05:14:23
【问题描述】:
在我的应用程序中,用户可以从不同的视频网站下载和播放视频,如 bofunk.com、dailymotion.com、youtube.com、metacafe.com、stupid videos.com 等。从不同网站下载视频的想法是什么.我实现了一个方法并且正在为某些站点工作。即通过从 html 字符串生成可下载的 url。但是同样的方法不适用于其他站点。任何人都可以指导我吗?提前谢谢。这就是我已经尝试并正在为 bofunk.com 工作
`-(BOOL)searchForVideoInBOFUNKHTML:(NSString*)htmlString;
{
NSString *strHTML=[NSString stringWithFormat:@"%@",htmlString];
NSString *newString;
if ([htmlString rangeOfString:@"id=\"vidplaya\""].location == NSNotFound)
{
return false;
}
else
{
htmlString = [strHTML substringFromIndex:[htmlString rangeOfString:@"id=\"vidplaya\""].location];
htmlString= [htmlString stringByReplacingOccurrencesOfString:[htmlString substringFromIndex:100]
withString:@""];
newString =[htmlString stringByReplacingOccurrencesOfString:[htmlString substringFromIndex:[htmlString rangeOfString:@"quality"].location] withString:@""];
NSLog(@"%@",newString);
newString = [[[newString substringFromIndex:[newString rangeOfString:@"/"].location] substringFromIndex:3] stringByReplacingOccurrencesOfString:@"\"" withString:@""];
NSLog(@"%@",newString);
newString = [newString stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"%@",newString);
embededURL = [[NSString alloc] initWithFormat:@"http://media.bofunk.com/media/flvs/%@.flv",newString];
NSLog(@"%@",embededURL);
return true;
}
return false;
}
`但不适用于dailymotion.com 之类的网站。这是与这些网站上的任何类型的加密有关的问题吗?
【问题讨论】:
-
您是否确认您的程序创建的 URL 确实正确?例如获取为 dailymotion 生成的 URL,将其粘贴到浏览器中并查看结果
-
@patrix 是的,我检查了。为 bofunk.com 生成的 url 被粘贴在浏览器上并直接下载视频。但是当尝试使用为 dailymotion.com 生成的 url 时,它只是在播放视频在浏览器上。可能是什么原因?
-
这是错误的 URL :-) 或者 dailymotion.com 不允许下载。或者,您需要查看 dailymotion.com 页面的 HTML 代码,以确定视频的直接 URL。也许他们甚至提供了一个 API 来直接访问视频。
标签: iphone objective-c xcode video download