Commit 9c1bebf3 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

[Online Resource Providers] Support object downloadUrls arrays

parent 6a8b0984
......@@ -466,11 +466,20 @@ std::pair<QList<ResourceItemInfo>, const int> ProviderModel::parseSearchResponse
: objectGetValue(item.toObject(), "duration").toInt();
if (keys["downloadUrls"].isObject()) {
for (const auto urlItem : objectGetValue(item.toObject(), "downloadUrls.key").toArray()) {
onlineItem.downloadUrls << objectGetString(urlItem.toObject(), "downloadUrls.url");
onlineItem.downloadLabels << objectGetString(urlItem.toObject(), "downloadUrls.name");
if (keys["downloadUrls"].toObject()["isObject"].toBool(false)) {
QJsonObject list = objectGetValue(item.toObject(), "downloadUrls.key").toObject();
for (const auto &key : list.keys()) {
QJsonObject urlItem = list[key].toObject();
onlineItem.downloadUrls << objectGetString(urlItem, "downloadUrls.url", QString(), key);
onlineItem.downloadLabels << objectGetString(urlItem, "downloadUrls.name", QString(), key);
}
} else {
for (const auto urlItem : objectGetValue(item.toObject(), "downloadUrls.key").toArray()) {
onlineItem.downloadUrls << objectGetString(urlItem.toObject(), "downloadUrls.url");
onlineItem.downloadLabels << objectGetString(urlItem.toObject(), "downloadUrls.name");
}
}
if (onlineItem.previewUrl.isEmpty()) {
if (onlineItem.previewUrl.isEmpty() && !onlineItem.downloadUrls.isEmpty()) {
onlineItem.previewUrl = onlineItem.downloadUrls.first();
}
} else if (keys["downloadUrl"].isString()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment