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:
Qt Code:
  1. QString video_url = "http://youtube.com/get_video";
  2. QString argument = "?video_id=Th7-EzW0Ccw&t=vjVQa1PpcFNQDXk1DXroxSYaUxdfZ23C8lngRxA5rvs=&fmt=18";
  3. QString dest = "/home/faster/video.mp4";
  4.  
  5. QUrl url(video_url);
  6. QFileInfo fileInfo(url.path());
  7. QString fileName = fileInfo.fileName();
  8. if (fileName.isEmpty())
  9. fileName = "index.html";
  10.  
  11. file = new QFile(dest);
  12.  
  13. QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
  14. http->setHost(url.host(), mode, url.port() != -1 ? url.port() : 80);
  15.  
  16. if (!url.userName().isEmpty())
  17. http->setUser(url.userName(), url.password());
  18.  
  19. httpRequestAborted = false;
  20. QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
  21. if (path.isEmpty())
  22. path = "/";
  23. httpGetId = http->get(video_url+argument, file);
To copy to clipboard, switch view to plain text mode