1 #include "ytstandardfeed.h"
3 #include "networkaccess.h"
5 #include "ytfeedreader.h"
11 YTStandardFeed::YTStandardFeed(QObject *parent)
12 : VideoSource(parent),
15 void YTStandardFeed::loadVideos(int max, int skip) {
18 QString s = "http://gdata.youtube.com/feeds/api/standardfeeds/";
19 if (!regionId.isEmpty()) s += regionId + "/";
21 if (!category.isEmpty()) s += "_" + category;
24 url.addQueryItem("v", "2");
26 if (feedId != "most_shared")
27 url.addQueryItem("time", "today");
29 url.addQueryItem("max-results", QString::number(max));
30 url.addQueryItem("start-index", QString::number(skip));
32 QObject *reply = The::http()->get(url);
33 connect(reply, SIGNAL(data(QByteArray)), SLOT(parse(QByteArray)));
34 connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
37 void YTStandardFeed::abort() {
41 const QStringList & YTStandardFeed::getSuggestions() {
42 QStringList *l = new QStringList();
46 void YTStandardFeed::parse(QByteArray data) {
49 YTFeedReader reader(data);
50 QList<Video*> videos = reader.getVideos();
52 emit gotVideos(videos);
53 emit finished(videos.size());
56 void YTStandardFeed::requestError(QNetworkReply *reply) {
57 emit error(reply->errorString());