3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
6 Minitube is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Minitube is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Minitube. If not, see <http://www.gnu.org/licenses/>.
21 #include "ytstandardfeed.h"
23 #include "networkaccess.h"
25 #include "ytfeedreader.h"
28 NetworkAccess* http();
31 YTStandardFeed::YTStandardFeed(QObject *parent)
32 : VideoSource(parent),
35 void YTStandardFeed::loadVideos(int max, int skip) {
38 QString s = "http://gdata.youtube.com/feeds/api/standardfeeds/";
39 if (!regionId.isEmpty()) s += regionId + "/";
41 if (!category.isEmpty()) s += "_" + category;
44 url.addQueryItem("v", "2");
46 if (feedId != "most_shared" && feedId != "on_the_web") {
48 if (t.isEmpty()) t = "today";
49 url.addQueryItem("time", t);
52 url.addQueryItem("max-results", QString::number(max));
53 url.addQueryItem("start-index", QString::number(skip));
55 QObject *reply = The::http()->get(url);
56 connect(reply, SIGNAL(data(QByteArray)), SLOT(parse(QByteArray)));
57 connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
60 void YTStandardFeed::abort() {
64 const QStringList & YTStandardFeed::getSuggestions() {
65 QStringList *l = new QStringList();
69 void YTStandardFeed::parse(QByteArray data) {
72 YTFeedReader reader(data);
73 QList<Video*> videos = reader.getVideos();
75 emit gotVideos(videos);
76 emit finished(videos.size());
79 void YTStandardFeed::requestError(QNetworkReply *reply) {
80 emit error(reply->errorString());