]> git.sur5r.net Git - minitube/blobdiff - src/video.cpp
Imported Upstream version 1.4.1
[minitube] / src / video.cpp
index 7b7a803de33d28ca07a891e0690cf9a9192d9a6b..df2c9fe8848bac9be9c651b90093e34348b1514a 100644 (file)
@@ -76,6 +76,9 @@ void  Video::getVideoInfo() {
     static const QStringList elTypes = QStringList() << "&el=embedded" << "&el=vevo" << "&el=detailpage" << "";
 
     if (elIndex > elTypes.size() - 1) {
+        loadingStreamUrl = false;
+        emit errorStreamUrl("Cannot get video info");
+        /*
         // Don't panic! We have a plan B.
         // get the youtube video webpage
         qDebug() << "Scraping" << webpage().toString();
@@ -83,6 +86,7 @@ void  Video::getVideoInfo() {
         connect(reply, SIGNAL(data(QByteArray)), SLOT(scrapeWebPage(QByteArray)));
         connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(errorVideoInfo(QNetworkReply*)));
         // see you in scrapWebPage(QByteArray)
+        */
         return;
     }
 
@@ -148,8 +152,10 @@ void  Video::gotVideoInfo(QByteArray data) {
         QString url = formatUrl.mid(separator + 1);
 
         if (format == definitionCode) {
+            qDebug() << "Found format" << definitionCode;
             QUrl videoUrl = QUrl::fromEncoded(url.toUtf8(), QUrl::StrictMode);
             m_streamUrl = videoUrl;
+            this->definitionCode = definitionCode;
             emit gotStreamUrl(videoUrl);
             loadingStreamUrl = false;
             return;
@@ -169,6 +175,7 @@ void  Video::gotVideoInfo(QByteArray data) {
             QString url = urlMap.value(definitionCode);
             QUrl videoUrl = QUrl::fromEncoded(url.toUtf8(), QUrl::StrictMode);
             m_streamUrl = videoUrl;
+            this->definitionCode = definitionCode;
             emit gotStreamUrl(videoUrl);
             loadingStreamUrl = false;
             return;
@@ -188,13 +195,13 @@ void Video::foundVideoUrl(QString videoToken, int definitionCode) {
             ).arg(videoId, videoToken, QString::number(definitionCode)));
 
     m_streamUrl = videoUrl;
-    emit gotStreamUrl(videoUrl);
     loadingStreamUrl = false;
+    emit gotStreamUrl(videoUrl);
 }
 
 void Video::errorVideoInfo(QNetworkReply *reply) {
-    emit errorStreamUrl(tr("Network error: %1 for %2").arg(reply->errorString(), reply->url().toString()));
     loadingStreamUrl = false;
+    emit errorStreamUrl(tr("Network error: %1 for %2").arg(reply->errorString(), reply->url().toString()));
 }
 
 void Video::scrapeWebPage(QByteArray data) {