Now downloading feeds.

This commit is contained in:
Martin Rotter 2017-09-26 13:44:07 +02:00
parent eef67ccba0
commit c3a914af1b

View File

@ -28,6 +28,7 @@
#include "network-web/webfactory.h"
#include "services/abstract/category.h"
#include "services/inoreader/definitions.h"
#include "services/inoreader/inoreaderfeed.h"
#include <QJsonArray>
#include <QJsonDocument>
@ -143,5 +144,37 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
}
}
json = QJsonDocument::fromJson(feeds.toUtf8()).object()["subscriptions"].toArray();
foreach (const QJsonValue& obj, json) {
auto subscription = obj.toObject();
QString id = subscription["id"].toString();
QString title = subscription["title"].toString();
QString url = subscription["htmlUrl"].toString();
QString parent_label;
QJsonArray categories = subscription["categories"].toArray();
foreach (const QJsonValue& cat, categories) {
QString potential_id = cat.toObject()["id"].toString();
if (potential_id.contains(QSL("/label/"))) {
parent_label = potential_id;
break;
}
}
// We have label (not "state").
InoreaderFeed* feed = new InoreaderFeed();
feed->setDescription(url);
feed->setUrl(url);
feed->setTitle(title);
feed->setCustomId(id);
if (cats.contains(parent_label)) {
cats[parent_label]->appendChild(feed);
}
}
return parent;
}