aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--plugins/Mangadex.hpp1
-rw-r--r--src/plugins/Mangadex.cpp30
3 files changed, 28 insertions, 5 deletions
diff --git a/README.md b/README.md
index e213b78..1b3e16c 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,7 @@ Type text and then wait and QuickMedia will automatically search.\
`F5`: Reload the video/music.
### Youtube channel controls
`Ctrl+T`: Subscribe/Unsubscribe from the channel.
-### Manga search page controls
+### Manga search/history page controls
`Ctrl+B`: Bookmark the selected manga. If the manga is already bookmarked then its removed from bookmarks.
### Manga page view controls
`Up`/`Ctrl+K`: Go to the next page (or chapter if the current page is the last one).\
diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp
index 1bc4b21..cb412da 100644
--- a/plugins/Mangadex.hpp
+++ b/plugins/Mangadex.hpp
@@ -20,6 +20,7 @@ namespace QuickMedia {
ChapterImageUrls chapter_image_urls;
private:
+ // Cover id should be set in the body items thumbnail url
PluginResult get_cover_urls(BodyItems &body_items);
SearchResult search(const std::string &str, int page, BodyItems &result_items);
bool get_rememberme_token(std::string &rememberme_token);
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));
}