aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Mangadex.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 5b8debd..1553d82 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -90,11 +90,10 @@ namespace QuickMedia {
if(body_items.empty())
return PluginResult::OK;
- std::string url = "https://api.mangadex.org/cover?";
+ std::string url = "https://api.mangadex.org/cover?limit=100&order[updatedAt]=desc";
for(size_t i = 0; i < body_items.size(); ++i) {
- if(i > 0)
- url += "&";
- url += "manga[]=" + body_items[i]->url;
+ if(!body_items[i]->thumbnail_url.empty())
+ url += "&ids[]=" + body_items[i]->thumbnail_url;
}
Json::Value json_root;
@@ -143,6 +142,27 @@ namespace QuickMedia {
return PluginResult::OK;
}
+
+ static std::string relationships_get_cover_art(const Json::Value &relationships_json) {
+ std::string result;
+ if(!relationships_json.isArray())
+ return result;
+
+ for(const Json::Value &relationship_json : relationships_json) {
+ if(!relationship_json.isObject())
+ continue;
+
+ const Json::Value &id_json = relationship_json["id"];
+ const Json::Value &relationship_type_json = relationship_json["type"];
+ if(!id_json.isString() || !relationship_type_json.isString() || strcmp(relationship_type_json.asCString(), "cover_art") != 0)
+ continue;
+
+ result = id_json.asString();
+ break;
+ }
+
+ return result;
+ }
SearchResult MangadexSearchPage::search(const std::string &str, int page, BodyItems &result_items) {
std::string url = "https://api.mangadex.org/manga?title=" + url_param_encode(str) + "&limit=20&offset=" + std::to_string(page * 20);
@@ -199,6 +219,8 @@ namespace QuickMedia {
body_item->set_description_color(get_current_theme().faded_text_color);
}
}
+
+ body_item->thumbnail_url = relationships_get_cover_art(result_item_json["relationships"]);
result_items.push_back(std::move(body_item));
}