aboutsummaryrefslogtreecommitdiff
path: root/plugins/NyaaSi.hpp
blob: 45c2f7b199455ab05508ba00d830886e572281b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include "Page.hpp"

namespace QuickMedia {
    void get_nyaa_si_categories(BodyItems &result_items);
    void get_sukebei_categories(BodyItems &result_items);

    class NyaaSiCategoryPage : public Page {
    public:
        NyaaSiCategoryPage(Program *program, bool is_sukebei) : Page(program), is_sukebei(is_sukebei) {}
        const char* get_title() const override { return is_sukebei ? "Select sukebei category" : "Select nyaa.si category"; }
        PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
        bool clear_search_after_submit() override { return true; }

        const bool is_sukebei;
    };

    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(); }
        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;

        const std::string category_name;
        const std::string category_id;
        const std::string domain;
    };

    class NyaaSiTorrentPage : public Page {
    public:
        NyaaSiTorrentPage(Program *program) : Page(program) {}
        const char* get_title() const override { return "Torrent"; }
        PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
    };
}