From 27e748dec4792ac8612fb77e21a6d857a41a816c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Oct 2020 09:49:25 +0200 Subject: Nyaa.si: fetch next page when reaching the bottom --- src/plugins/NyaaSi.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index 98c6eee..1cdfc5f 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -71,10 +71,19 @@ namespace QuickMedia { return PluginResult::OK; } + + SearchResult NyaaSi::content_list_search(const std::string &list_url, const std::string &text, BodyItems &result_items) { + return search_page(list_url, text, 1, result_items); + } + + SearchResult NyaaSi::content_list_search_page(const std::string &list_url, const std::string &text, int page, BodyItems &result_items) { + return search_page(list_url, text, 1 + page, result_items); + } + // TODO: Also show the number of comments for each torrent. TODO: Optimize? // TODO: Show each field as seperate columns instead of seperating by | - SearchResult NyaaSi::content_list_search(const std::string &list_url, const std::string &text, BodyItems &result_items) { - std::string full_url = "https://nyaa.si/?c=" + list_url + "&f=0&p=1&q="; + SearchResult NyaaSi::search_page(const std::string &list_url, const std::string &text, int page, BodyItems &result_items) { + std::string full_url = "https://nyaa.si/?c=" + list_url + "&f=0&p=" + std::to_string(page) + "&q="; full_url += url_param_encode(text); std::string website_data; @@ -218,7 +227,7 @@ namespace QuickMedia { } PluginResult NyaaSi::get_content_list(const std::string &url, BodyItems &result_items) { - return search_result_to_plugin_result(content_list_search(url, "", result_items)); + return search_result_to_plugin_result(search_page(url, "", 1, result_items)); } struct BodyItemImageContext { -- cgit v1.2.3