X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fytstandardfeed.cpp;h=59ce7304c857ef111a10c6209ef9bc24545a55c2;hb=e5ab28f93dda6e878973f57276db5edab68d13bc;hp=50e0674318605a8d1d4c2a61a282ec8cb0308e66;hpb=7cdd5bd476021ec84d54c4ec5be02280e1e9e548;p=minitube
diff --git a/src/ytstandardfeed.cpp b/src/ytstandardfeed.cpp
index 50e0674..59ce730 100644
--- a/src/ytstandardfeed.cpp
+++ b/src/ytstandardfeed.cpp
@@ -19,54 +19,119 @@ along with Minitube. If not, see .
$END_LICENSE */
#include "ytstandardfeed.h"
-#include
#include "networkaccess.h"
#include "video.h"
+
+#ifdef APP_YT3
+#include "yt3.h"
+#include "yt3listparser.h"
+#else
#include "ytfeedreader.h"
+#endif
namespace The {
NetworkAccess* http();
}
YTStandardFeed::YTStandardFeed(QObject *parent)
- : VideoSource(parent),
+ : PaginatedVideoSource(parent),
aborted(false) { }
-void YTStandardFeed::loadVideos(int max, int skip) {
+#ifdef APP_YT3
+
+void YTStandardFeed::loadVideos(int max, int startIndex) {
aborted = false;
- QString s = "http://gdata.youtube.com/feeds/api/standardfeeds/";
- if (!regionId.isEmpty()) s += regionId + "/";
- s += feedId;
- if (!category.isEmpty()) s += "_" + category;
+ QUrl url = YT3::instance().method("videos");
- QUrl url(s);
- url.addQueryItem("v", "2");
+#if QT_VERSION >= 0x050000
+ {
+ QUrl &u = url;
+ QUrlQuery url;
+#endif
- if (feedId != "most_shared" && feedId != "on_the_web") {
- QString t = time;
- if (t.isEmpty()) t = "today";
- url.addQueryItem("time", t);
- }
+ if (startIndex > 1) {
+ if (maybeReloadToken(max, startIndex)) return;
+ url.addQueryItem("pageToken", nextPageToken);
+ }
+
+ url.addQueryItem("part", "snippet,contentDetails,statistics");
+ url.addQueryItem("chart", "mostPopular");
+
+ if (!category.isEmpty())
+ url.addQueryItem("videoCategoryId", category);
- url.addQueryItem("max-results", QString::number(max));
- url.addQueryItem("start-index", QString::number(skip));
+ if (!regionId.isEmpty())
+ url.addQueryItem("regionCode", regionId);
+ url.addQueryItem("maxResults", QString::number(max));
+
+#if QT_VERSION >= 0x050000
+ u.setQuery(url);
+ }
+#endif
QObject *reply = The::http()->get(url);
- connect(reply, SIGNAL(data(QByteArray)), SLOT(parse(QByteArray)));
+ connect(reply, SIGNAL(data(QByteArray)), SLOT(parseResults(QByteArray)));
connect(reply, SIGNAL(error(QNetworkReply*)), SLOT(requestError(QNetworkReply*)));
}
-void YTStandardFeed::abort() {
- aborted = true;
+void YTStandardFeed::parseResults(QByteArray data) {
+ if (aborted) return;
+
+ YT3ListParser parser(data);
+ QList