]> git.sur5r.net Git - minitube/commitdiff
Fixed definition code property
authorFlavio <flavio@odisseo.local>
Sat, 29 Jan 2011 21:08:59 +0000 (22:08 +0100)
committerFlavio <flavio@odisseo.local>
Sat, 29 Jan 2011 21:08:59 +0000 (22:08 +0100)
src/video.cpp
src/video.h

index d0eb7c08e79fd934ac7b09bbafb95ab35bcc2173..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;
     }
 
@@ -151,6 +155,7 @@ void  Video::gotVideoInfo(QByteArray data) {
             qDebug() << "Found format" << definitionCode;
             QUrl videoUrl = QUrl::fromEncoded(url.toUtf8(), QUrl::StrictMode);
             m_streamUrl = videoUrl;
+            this->definitionCode = definitionCode;
             emit gotStreamUrl(videoUrl);
             loadingStreamUrl = false;
             return;
@@ -170,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;
@@ -189,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) {
index 68a17f542f0ef08420524983df0adbe445e7b163..c7b01651fcd874653e7a86c8530917e87cd475a4 100644 (file)
@@ -41,7 +41,7 @@ public:
     const QDateTime published() const { return m_published; }
     void setPublished( QDateTime published ) { m_published = published; }
 
-    bool getDefinitionCode() const { return definitionCode; }
+    int getDefinitionCode() const { return definitionCode; }
 
     void loadStreamUrl();
     QUrl getStreamUrl() { return m_streamUrl; }