From aa9a861c662f7c65cde92fbf133deaca3692bbd2 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 23 Oct 2020 07:42:13 +0200 Subject: Mangadex: implement pagination --- src/plugins/Mangadex.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp index e798b60..a52788d 100644 --- a/src/plugins/Mangadex.cpp +++ b/src/plugins/Mangadex.cpp @@ -55,14 +55,12 @@ namespace QuickMedia { bool *is_last_page; }; - // TODO: Implement pagination (go to next page and get all results as well) - SearchResult MangadexSearchPage::search(const std::string &str, BodyItems &result_items) { + SearchResult MangadexSearchPage::search(const std::string &str, int page, BodyItems &result_items) { std::string rememberme_token; if(!get_rememberme_token(rememberme_token)) return SearchResult::ERR; - std::string url = "https://mangadex.org/search?title="; - url += url_param_encode(str); + std::string url = "https://mangadex.org/search?s=0&p=" + std::to_string(page) + "&tag_mode_inc=all&tag_mode_exc=any&title=" + url_param_encode(str) +"#listing"; CommandArg cookie_arg = { "-H", "cookie: mangadex_rememberme_token=" + rememberme_token }; std::string website_data; @@ -111,6 +109,14 @@ namespace QuickMedia { return result == 0 ? SearchResult::OK : SearchResult::ERR; } + SearchResult MangadexSearchPage::search(const std::string &str, BodyItems &result_items) { + return search(str, 1, result_items); + } + + PluginResult MangadexSearchPage::get_page(const std::string &str, int page, BodyItems &result_items) { + return search_result_to_plugin_result(search(str, 1 + page, result_items)); + } + PluginResult MangadexSearchPage::submit(const std::string &title, const std::string &url, std::vector &result_tabs) { std::string request_url = "https://mangadex.org/api/?id=" + title_url_extract_manga_id(url) + "&type=manga"; -- cgit v1.2.3