#include "video.h"
IVVideoList::IVVideoList(const QString &req, const QString &name, QObject *parent)
- : VideoSource(parent), name(name), req(req) {}
+ : IVVideoSource(parent), name(name), req(req) {}
-void IVVideoList::loadVideos(int max, int startIndex) {
+void IVVideoList::reallyLoadVideos(int max, int startIndex) {
aborted = false;
QUrl url(Invidious::instance().baseUrl() + req);
connect(reply, &HttpReply::data, this, [this](auto data) {
QJsonDocument doc = QJsonDocument::fromJson(data);
const QJsonArray items = doc.array();
+ if (items.isEmpty()) {
+ handleError("No videos");
+ return;
+ }
+
IVListParser parser(items);
const QVector<Video *> &videos = parser.getVideos();
- qDebug() << "CAOCAO" << req << name << videos.size();
emit gotVideos(videos);
emit finished(videos.size());
});
- connect(reply, &HttpReply::error, this, [this](auto message) {
- Invidious::instance().initServers();
- emit error(message);
- });
-}
-
-void IVVideoList::abort() {
- aborted = true;
+ connect(reply, &HttpReply::error, this, &IVVideoList::handleError);
}