From 07a66f12db9591ab1cca0475b3d0dde3f6ff150e Mon Sep 17 00:00:00 2001 From: Flavio Date: Wed, 26 Jan 2011 01:09:51 +0100 Subject: [PATCH] Channels! --- src/searchparams.h | 4 ++++ src/youtubesearch.cpp | 22 +++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/searchparams.h b/src/searchparams.h index e8525c9..7f1a44c 100644 --- a/src/searchparams.h +++ b/src/searchparams.h @@ -13,6 +13,9 @@ public: const QString keywords() const { return m_keywords; } void setKeywords( QString keywords ) { m_keywords = keywords; } + const QString author() const { return m_author; } + void setAuthor( QString author ) { m_author = author; } + int sortBy() const { return m_sortBy; } void setSortBy( int sortBy ) { m_sortBy = sortBy; } @@ -24,6 +27,7 @@ public: private: QString m_keywords; + QString m_author; int m_sortBy; }; diff --git a/src/youtubesearch.cpp b/src/youtubesearch.cpp index 6bb66cb..a57b7c2 100644 --- a/src/youtubesearch.cpp +++ b/src/youtubesearch.cpp @@ -12,27 +12,23 @@ YouTubeSearch::YouTubeSearch() : QObject() {} void YouTubeSearch::search(SearchParams *searchParams, int max, int skip) { this->abortFlag = false; - QString urlString = QString( - "http://gdata.youtube.com/feeds/api/videos?q=%1&max-results=%2&start-index=%3") - .arg(searchParams->keywords(), QString::number(max), QString::number(skip)); - - // Useful to test with a local webserver - /* - urlString = QString("http://localhost/~flavio/text.xml?q=%1&max-results=%2&start-index=%3") - .arg(searchParams->keywords(), QString::number(max), QString::number(skip)); - */ + QUrl url("http://gdata.youtube.com/feeds/api/videos"); + url.addQueryItem("max-results", QString::number(max)); + url.addQueryItem("start-index", QString::number(skip)); + if (!searchParams->keywords().isEmpty()) + url.addQueryItem("q", searchParams->keywords()); + if (!searchParams->author().isEmpty()) + url.addQueryItem("author", searchParams->author()); switch (searchParams->sortBy()) { case SearchParams::SortByNewest: - urlString.append("&orderby=published"); + url.addQueryItem("orderby", "published"); break; case SearchParams::SortByViewCount: - urlString.append("&orderby=viewCount"); + url.addQueryItem("orderby", "viewCount"); break; } - QUrl url(urlString); - QObject *reply = The::http()->get(url); connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResults(QByteArray))); connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(error(QNetworkReply*))); -- 2.39.5