pull out a single photo url and thumbnail if it exists

This commit is contained in:
Morgan McMillian 2018-04-08 07:41:14 -07:00
parent 6473657bf8
commit 97ce9579ec

View file

@ -559,7 +559,26 @@ QVariantList Pnut::parseStream(QVariantList stream)
item = item["repost_of"].toMap();
item.insert("reposted_by", username);
}
if (item.find("raw") != item.end())
{
QVariantList rawlist = item["raw"].toList();
foreach (QVariant ritem, rawlist) {
QVariantMap raw = ritem.toMap();
if (raw["type"] == "io.pnut.core.oembed")
{
QVariantMap value = raw["value"].toMap();
if (value["type"] == "photo")
{
item.insert("photo_url", value["url"].toString());
if (value.find("thumbnail_url") != value.end())
{
item.insert("thumbnail_url", value["thumbnail_url"].toString());
}
}
}
}
}
pstream.append(item);
}
return pstream; // but not really
return pstream;
}