More fixes for Danbooru's braindead API results
This commit is contained in:
parent
6fc03fe504
commit
17e399bbcd
1 changed files with 19 additions and 16 deletions
|
@ -37,24 +37,27 @@ const QMap<QString, DanbooruPost::Rating> DanbooruPost::RATING_MAP = initRatingM
|
|||
|
||||
void DanbooruPost::parseDanbooruDonmai(const QVariantMap &postData) {
|
||||
|
||||
m_tags = QSet<QString>::fromList(postData.value("tag_string").toString().split(' '));
|
||||
m_id = postData.value("id").toString().toInt();
|
||||
if (postData.contains("image_width")) {
|
||||
m_width = postData.value("image_width").toString().toInt();
|
||||
} else if (postData.contains("image-width")) {
|
||||
m_width = postData.value("image-width").toString().toInt();
|
||||
}
|
||||
if (postData.contains("image_height")) {
|
||||
m_height = postData.value("image_height").toString().toInt();
|
||||
} else if (postData.contains("image-height")) {
|
||||
m_height = postData.value("image-height").toString().toInt();
|
||||
}
|
||||
// HACK: Handle XML (foo-bar) versus JSON (foo_bar) for attributes
|
||||
|
||||
m_url = postData.value("file_url").toUrl();
|
||||
m_thumbnailUrl = postData.value("preview_file_url").toUrl();
|
||||
m_size = postData.value("file_size").toInt();
|
||||
auto tagString = postData.contains("tag_string") ? QLatin1String("tag_string"): QLatin1String("tag-string");
|
||||
auto width = postData.contains("image_width") ? QLatin1String("image_width"): QLatin1String("image-width");
|
||||
auto height = postData.contains("image_height") ? QLatin1String("image_height"): QLatin1String("image-height");
|
||||
auto fileSize = postData.contains("file_size") ? QLatin1String("file_size"): QLatin1String("file-size");
|
||||
auto fileUrl = postData.contains("file_url") ? QLatin1String("file_url"): QLatin1String("file-url");
|
||||
auto thumbnailUrl = postData.contains("preview_file_url") ? QLatin1String("preview_file_url"): QLatin1String("preview-file-url");
|
||||
auto sampleUrl = postData.contains("large_file_url") ? QLatin1String("large_file_url"): QLatin1String("large-file-url");
|
||||
|
||||
m_id = postData.value("id").toString().toInt();
|
||||
m_tags = QSet<QString>::fromList(postData.value(tagString).toString().split(' '));
|
||||
|
||||
m_width = postData.value(width).toString().toInt();
|
||||
m_height = postData.value(height).toString().toInt();
|
||||
|
||||
m_url = postData.value(fileUrl).toUrl();
|
||||
m_thumbnailUrl = postData.value(thumbnailUrl).toUrl();
|
||||
m_size = postData.value(fileSize).toInt();
|
||||
m_rating = RATING_MAP.value(postData.value("rating").toString());
|
||||
m_sampleUrl = postData.value("large_file_url").toUrl();
|
||||
m_sampleUrl = postData.value(sampleUrl).toUrl();
|
||||
}
|
||||
|
||||
void DanbooruPost::parseDanbooruDonmai(const QXmlStreamAttributes &postData) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue