Hi, what qt4 class could I use to download a video from youtube? I need to download a video from an url like this: http://youtube.com/get_video?video_i...xA5rvs=&fmt=18. Firefox download this video but Qhttp fails to download. Any suggestions?
This is my code:
QString video_url
= "http://youtube.com/get_video";
QString argument
= "?video_id=Th7-EzW0Ccw&t=vjVQa1PpcFNQDXk1DXroxSYaUxdfZ23C8lngRxA5rvs=&fmt=18";
QString dest
= "/home/faster/video.mp4";
QString fileName
= fileInfo.
fileName();
if (fileName.isEmpty())
fileName = "index.html";
QHttp::ConnectionMode mode
= url.
scheme().
toLower() == "https" ?
QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
http->setHost(url.host(), mode, url.port() != -1 ? url.port() : 80);
if (!url.userName().isEmpty())
http->setUser(url.userName(), url.password());
httpRequestAborted = false;
QByteArray path
= QUrl::toPercentEncoding(url.
path(),
"!$&'()*+,;=:@/");
if (path.isEmpty())
path = "/";
httpGetId = http->get(video_url+argument, file);
QString video_url = "http://youtube.com/get_video";
QString argument = "?video_id=Th7-EzW0Ccw&t=vjVQa1PpcFNQDXk1DXroxSYaUxdfZ23C8lngRxA5rvs=&fmt=18";
QString dest = "/home/faster/video.mp4";
QUrl url(video_url);
QFileInfo fileInfo(url.path());
QString fileName = fileInfo.fileName();
if (fileName.isEmpty())
fileName = "index.html";
file = new QFile(dest);
QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
http->setHost(url.host(), mode, url.port() != -1 ? url.port() : 80);
if (!url.userName().isEmpty())
http->setUser(url.userName(), url.password());
httpRequestAborted = false;
QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
if (path.isEmpty())
path = "/";
httpGetId = http->get(video_url+argument, file);
To copy to clipboard, switch view to plain text mode
Bookmarks