diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-07-16 07:31:02 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-07-16 07:31:02 +0200 |
commit | b09d1e70661226697e2441c18ea6ff59c387fb93 (patch) | |
tree | 66f75dbc0237407912c522a54c7a46f9987f4642 /plugins | |
parent | 2167a32f3730e569a636d9b041122558aceb89f1 (diff) |
Add sorting options to nyaa.si
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NyaaSi.hpp | 34 | ||||
-rw-r--r-- | plugins/Page.hpp | 1 |
2 files changed, 33 insertions, 2 deletions
diff --git a/plugins/NyaaSi.hpp b/plugins/NyaaSi.hpp index 897c5ab..6f161ac 100644 --- a/plugins/NyaaSi.hpp +++ b/plugins/NyaaSi.hpp @@ -16,18 +16,48 @@ namespace QuickMedia { const bool is_sukebei; }; + enum class NyaaSiSortType { + SIZE_DESC, + UPLOAD_DATE_DESC, + SEEDERS_DESC, + LEECHERS_DESC, + DOWNLOADS_DESC, + + SIZE_ASC, + UPLOAD_DATE_ASC, + SEEDERS_ASC, + LEECHERS_ASC, + DOWNLOADS_ASC + }; + class NyaaSiSearchPage : public Page { public: - NyaaSiSearchPage(Program *program, std::string category_name, std::string category_id, std::string domain) : Page(program), category_name(std::move(category_name)), category_id(std::move(category_id)), domain(std::move(domain)) {} - const char* get_title() const override { return category_name.c_str(); } + NyaaSiSearchPage(Program *program, std::string category_name, std::string category_id, std::string domain); + const char* get_title() const override { return title.c_str(); } bool search_is_filter() override { return false; } SearchResult search(const std::string &str, BodyItems &result_items) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; + void set_sort_type(NyaaSiSortType sort_type); + const std::string category_name; const std::string category_id; const std::string domain; + private: + NyaaSiSortType sort_type = NyaaSiSortType::UPLOAD_DATE_DESC; + std::string title; + }; + + class NyaaSiSortOrderPage : public Page { + public: + NyaaSiSortOrderPage(Program *program, Body *body, NyaaSiSearchPage *search_page) : Page(program), body(body), search_page(search_page) {} + const char* get_title() const override { return "Sort order"; } + PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; + bool submit_is_async() override { return false; } + private: + Body *body; + NyaaSiSearchPage *search_page; }; class NyaaSiTorrentPage : public Page { diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 2d10d50..3a382ec 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -67,6 +67,7 @@ namespace QuickMedia { Program *program; std::shared_ptr<BodyItem> submit_body_item; // TODO: Remove this + bool needs_refresh = false; // Set to true to refresh the page }; enum class TrackResult { |