aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/NyaaSi.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-07 22:54:20 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-07 22:55:11 +0100
commit75c610d1f65d741bbeba9f1ddeef60a6e9315427 (patch)
tree0dd79a5a7f35c89b9672d55fbf24cb1f6de13aa9 /src/plugins/NyaaSi.cpp
parent9539a71dbeafdc4107d3b92eefada332ee45579a (diff)
Use one struct for all args in Page::submit instead of multiple args (easier to add new fields without changing code)
Also remove submit_body_item from page.
Diffstat (limited to 'src/plugins/NyaaSi.cpp')
-rw-r--r--src/plugins/NyaaSi.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp
index a110c57..fc3e7ee 100644
--- a/src/plugins/NyaaSi.cpp
+++ b/src/plugins/NyaaSi.cpp
@@ -284,14 +284,14 @@ namespace QuickMedia {
return SearchResult::OK;
}
- PluginResult NyaaSiCategoryPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult NyaaSiCategoryPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
std::string domain = is_sukebei ? "sukebei.nyaa.si" : "nyaa.si";
BodyItems result_items;
- SearchResult search_result = search_page(domain, url, "", 1, NyaaSiSortType::UPLOAD_DATE_DESC, result_items);
+ SearchResult search_result = search_page(domain, args.url, "", 1, NyaaSiSortType::UPLOAD_DATE_DESC, result_items);
if(search_result != SearchResult::OK) return search_result_to_plugin_result(search_result);
- auto search_page = std::make_unique<NyaaSiSearchPage>(program, strip(title), url, std::move(domain));
+ auto search_page = std::make_unique<NyaaSiSearchPage>(program, strip(args.title), args.url, std::move(domain));
NyaaSiSearchPage *search_page_p = search_page.get();
auto body = create_body();
body->set_items(std::move(result_items));
@@ -323,7 +323,7 @@ namespace QuickMedia {
const std::string *domain;
};
- PluginResult NyaaSiSearchPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult NyaaSiSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
size_t comments_start_index;
std::string title;
BodyItems result_items;
@@ -337,7 +337,7 @@ namespace QuickMedia {
result_item_extra.domain = &domain;
std::string website_data;
- if(download_to_string(url, website_data, {}, true) != DownloadResult::OK)
+ if(download_to_string(args.url, website_data, {}, true) != DownloadResult::OK)
return PluginResult::NET_ERR;
QuickMediaHtmlSearch html_search;
@@ -498,8 +498,8 @@ namespace QuickMedia {
title.erase(title.end() - 5, title.end()); // Erase emoji character and space at the end. TODO: Remove this when tabs support emojis.
}
- PluginResult NyaaSiSortOrderPage::submit(const std::string&, const std::string&, std::vector<Tab>&) {
- const NyaaSiSortType sort_type = (NyaaSiSortType)(size_t)submit_body_item->userdata;
+ PluginResult NyaaSiSortOrderPage::submit(const SubmitArgs &args, std::vector<Tab>&) {
+ const NyaaSiSortType sort_type = (NyaaSiSortType)(size_t)args.userdata;
body->clear_items();
sort_page_create_body_items(body, sort_type);
search_page->set_sort_type(sort_type);
@@ -507,15 +507,14 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult NyaaSiTorrentPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- (void)title;
+ PluginResult NyaaSiTorrentPage::submit(const SubmitArgs &submit_args, std::vector<Tab> &result_tabs) {
(void)result_tabs;
- if(strncmp(url.c_str(), "magnet:?", 8) == 0) {
+ if(strncmp(submit_args.url.c_str(), "magnet:?", 8) == 0) {
if(!is_program_executable_by_name("xdg-open")) {
show_notification("QuickMedia", "xdg-utils which provides xdg-open needs to be installed to download torrents", Urgency::CRITICAL);
return PluginResult::ERR;
}
- const char *args[] = { "xdg-open", url.c_str(), nullptr };
+ const char *args[] = { "xdg-open", submit_args.url.c_str(), nullptr };
exec_program_async(args, nullptr);
}
return PluginResult::OK;