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; }
private:
QString m_keywords;
+ QString m_author;
int m_sortBy;
};
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*)));