From a8387af928546f1d47d36d14b905f316f6908a13 Mon Sep 17 00:00:00 2001 From: Flavio Date: Sat, 29 Jan 2011 22:08:59 +0100 Subject: [PATCH] Fixed definition code property --- src/video.cpp | 10 ++++++++-- src/video.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/video.cpp b/src/video.cpp index d0eb7c0..df2c9fe 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -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) { diff --git a/src/video.h b/src/video.h index 68a17f5..c7b0165 100644 --- a/src/video.h +++ b/src/video.h @@ -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; } -- 2.39.5