aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
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
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')
-rw-r--r--src/plugins/AniList.cpp32
-rw-r--r--src/plugins/FileManager.cpp6
-rw-r--r--src/plugins/Fourchan.cpp10
-rw-r--r--src/plugins/HotExamples.cpp10
-rw-r--r--src/plugins/Info.cpp16
-rw-r--r--src/plugins/Lbry.cpp14
-rw-r--r--src/plugins/MangaCombined.cpp9
-rw-r--r--src/plugins/MangaGeneric.cpp17
-rw-r--r--src/plugins/Mangadex.cpp19
-rw-r--r--src/plugins/Manganelo.cpp18
-rw-r--r--src/plugins/Matrix.cpp32
-rw-r--r--src/plugins/MediaGeneric.cpp8
-rw-r--r--src/plugins/MyAnimeList.cpp16
-rw-r--r--src/plugins/NyaaSi.cpp21
-rw-r--r--src/plugins/Page.cpp8
-rw-r--r--src/plugins/Peertube.cpp22
-rw-r--r--src/plugins/Pipe.cpp6
-rw-r--r--src/plugins/Saucenao.cpp8
-rw-r--r--src/plugins/Soundcloud.cpp29
-rw-r--r--src/plugins/Youtube.cpp40
20 files changed, 162 insertions, 179 deletions
diff --git a/src/plugins/AniList.cpp b/src/plugins/AniList.cpp
index b892229..a41e644 100644
--- a/src/plugins/AniList.cpp
+++ b/src/plugins/AniList.cpp
@@ -517,13 +517,13 @@ query ($id: Int, $page: Int, $perPage: Int) {
return search_page(str, 1, result_items);
}
- PluginResult AniListSearchPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult AniListSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- result_tabs.push_back({ create_body(), std::make_unique<AniListDetailsPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(), std::make_unique<AniListRelatedPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(), std::make_unique<AniListRecommendationsPage>(program, url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListDetailsPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListRelatedPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListRecommendationsPage>(program, args.url), nullptr });
return PluginResult::OK;
}
@@ -531,13 +531,13 @@ query ($id: Int, $page: Int, $perPage: Int) {
return search_result_to_plugin_result(search_page(str, 1 + page, result_items));
}
- PluginResult AniListRelatedPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult AniListRelatedPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- result_tabs.push_back({ create_body(), std::make_unique<AniListDetailsPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(), std::make_unique<AniListRelatedPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(), std::make_unique<AniListRecommendationsPage>(program, url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListDetailsPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListRelatedPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListRecommendationsPage>(program, args.url), nullptr });
return PluginResult::OK;
}
@@ -626,7 +626,7 @@ query ($id: Int, $page: Int, $perPage: Int) {
return PluginResult::OK;
}
- PluginResult AniListDetailsPage::submit(const std::string&, const std::string&, std::vector<Tab>&) {
+ PluginResult AniListDetailsPage::submit(const SubmitArgs&, std::vector<Tab>&) {
return PluginResult::OK;
}
@@ -685,13 +685,13 @@ query ($id: Int, $page: Int, $perPage: Int) {
return PluginResult::OK;
}
- PluginResult AniListRecommendationsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult AniListRecommendationsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- result_tabs.push_back({ create_body(), std::make_unique<AniListDetailsPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(), std::make_unique<AniListRelatedPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(), std::make_unique<AniListRecommendationsPage>(program, url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListDetailsPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListRelatedPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<AniListRecommendationsPage>(program, args.url), nullptr });
return PluginResult::OK;
}
diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp
index 59d3a2a..eb4a3ef 100644
--- a/src/plugins/FileManager.cpp
+++ b/src/plugins/FileManager.cpp
@@ -27,12 +27,12 @@ namespace QuickMedia {
return "";
}
- PluginResult FileManagerPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult FileManagerPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
std::filesystem::path new_path;
- if(url == "..")
+ if(args.url == "..")
new_path = current_dir.parent_path();
else
- new_path = current_dir / url;
+ new_path = current_dir / args.url;
if(std::filesystem::is_regular_file(new_path)) {
program->select_file(new_path);
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index c906c4d..d3d5a5c 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -229,8 +229,8 @@ namespace QuickMedia {
return comment_text;
}
- PluginResult FourchanBoardsPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{create_body(false, true), std::make_unique<FourchanThreadListPage>(program, title, url), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
+ PluginResult FourchanBoardsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{create_body(false, true), std::make_unique<FourchanThreadListPage>(program, args.title, args.url), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
return PluginResult::OK;
}
@@ -272,9 +272,9 @@ namespace QuickMedia {
}
// TODO: Merge with lazy fetch
- PluginResult FourchanThreadListPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult FourchanThreadListPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
Json::Value json_root;
- DownloadResult result = download_json(json_root, fourchan_url + board_id + "/thread/" + url + ".json", {}, true);
+ DownloadResult result = download_json(json_root, fourchan_url + board_id + "/thread/" + args.url + ".json", {}, true);
if(result != DownloadResult::OK) return download_result_to_plugin_result(result);
if(!json_root.isObject())
@@ -366,7 +366,7 @@ namespace QuickMedia {
auto body = create_body(false);
body->set_items(std::move(result_items));
- result_tabs.push_back(Tab{std::move(body), std::make_unique<FourchanThreadPage>(program, board_id, url), nullptr});
+ result_tabs.push_back(Tab{std::move(body), std::make_unique<FourchanThreadPage>(program, board_id, args.url), nullptr});
return PluginResult::OK;
}
diff --git a/src/plugins/HotExamples.cpp b/src/plugins/HotExamples.cpp
index 043ddfd..fbefad5 100644
--- a/src/plugins/HotExamples.cpp
+++ b/src/plugins/HotExamples.cpp
@@ -21,8 +21,8 @@ namespace QuickMedia {
body_items.push_back(create_body_item_with_url("TypeScript", "typescript"));
}
- PluginResult HotExamplesLanguageSelectPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back({ create_body(), std::make_unique<HotExamplesSearchPage>(program, url), create_search_bar("Search...", 500) });
+ PluginResult HotExamplesLanguageSelectPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back({ create_body(), std::make_unique<HotExamplesSearchPage>(program, args.url), create_search_bar("Search...", 500) });
return PluginResult::OK;
}
@@ -82,10 +82,10 @@ namespace QuickMedia {
return SearchResult::OK;
}
- PluginResult HotExamplesSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult HotExamplesSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
BodyItems result_items;
std::string website_data;
- DownloadResult download_result = download_to_string(url, website_data, {}, true);
+ DownloadResult download_result = download_to_string(args.url, website_data, {}, true);
if(download_result != DownloadResult::OK) return download_result_to_plugin_result(download_result);
QuickMediaHtmlSearch html_search;
@@ -134,7 +134,7 @@ namespace QuickMedia {
auto body = create_body();
body->set_items(std::move(result_items));
- result_tabs.push_back({ std::move(body), std::make_unique<HotExamplesCodeExamplesPage>(program, title + " code examples"), create_search_bar("Search...", SEARCH_DELAY_FILTER) });
+ result_tabs.push_back({ std::move(body), std::make_unique<HotExamplesCodeExamplesPage>(program, args.title + " code examples"), create_search_bar("Search...", SEARCH_DELAY_FILTER) });
return PluginResult::OK;
}
} \ No newline at end of file
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index 2b520ac..90c8fe1 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -32,20 +32,20 @@ namespace QuickMedia {
return exec_program_async(args, nullptr) == 0 ? PluginResult::OK : PluginResult::ERR;
}
- PluginResult InfoPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(string_starts_with(url, REVERSE_IMAGE_SEARCH_URL)) {
- std::string image_url = url.substr(strlen(REVERSE_IMAGE_SEARCH_URL));
+ PluginResult InfoPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(string_starts_with(args.url, REVERSE_IMAGE_SEARCH_URL)) {
+ std::string image_url = args.url.substr(strlen(REVERSE_IMAGE_SEARCH_URL));
result_tabs.push_back(Tab{create_body(), std::make_unique<SaucenaoPage>(program, image_url, false), nullptr});
return PluginResult::OK;
- } else if(string_starts_with(url, GOOGLE_SEARCH_URL)) {
- const std::string search_term = url.substr(strlen(GOOGLE_SEARCH_URL));
+ } else if(string_starts_with(args.url, GOOGLE_SEARCH_URL)) {
+ const std::string search_term = args.url.substr(strlen(GOOGLE_SEARCH_URL));
const std::string search_url = "https://www.google.com/search?q=" + url_param_encode(search_term);
return open_with_browser(search_url);
- } else if(is_youtube_url(url)) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ } else if(is_youtube_url(args.url)) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
return PluginResult::OK;
} else {
- return open_with_browser(url);
+ return open_with_browser(args.url);
}
}
diff --git a/src/plugins/Lbry.cpp b/src/plugins/Lbry.cpp
index 50da718..73c37ba 100644
--- a/src/plugins/Lbry.cpp
+++ b/src/plugins/Lbry.cpp
@@ -247,11 +247,11 @@ namespace QuickMedia {
return resolve_claims(this, request_json, result_items);
}
- PluginResult LbrySearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- if(submit_body_item->userdata == search_type_video)
- result_tabs.push_back(Tab{ nullptr, std::make_unique<LbryVideoPage>(program, title, url), nullptr });
- else if(submit_body_item->userdata == search_type_channel)
- result_tabs.push_back(Tab{ create_body(false, true), std::make_unique<LbryChannelPage>(program, title, url), create_search_bar("Search...", 500) });
+ PluginResult LbrySearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.userdata == search_type_video)
+ result_tabs.push_back(Tab{ nullptr, std::make_unique<LbryVideoPage>(program, args.title, args.url), nullptr });
+ else if(args.userdata == search_type_channel)
+ result_tabs.push_back(Tab{ create_body(false, true), std::make_unique<LbryChannelPage>(program, args.title, args.url), create_search_bar("Search...", 500) });
return PluginResult::OK;
}
@@ -318,8 +318,8 @@ namespace QuickMedia {
return resolve_claims(this, request_json, result_items);
}
- PluginResult LbryChannelPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{ nullptr, std::make_unique<LbryVideoPage>(program, title, url), nullptr });
+ PluginResult LbryChannelPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{ nullptr, std::make_unique<LbryVideoPage>(program, args.title, args.url), nullptr });
return PluginResult::OK;
}
diff --git a/src/plugins/MangaCombined.cpp b/src/plugins/MangaCombined.cpp
index 06ecfc0..bc4043f 100644
--- a/src/plugins/MangaCombined.cpp
+++ b/src/plugins/MangaCombined.cpp
@@ -119,13 +119,10 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult MangaCombinedSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- Page *page = (Page*)submit_body_item->userdata;
+ PluginResult MangaCombinedSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ Page *page = (Page*)args.userdata;
if(!page) return PluginResult::OK;
- page->submit_body_item = submit_body_item;
- PluginResult result = page->submit(title, url, result_tabs);
- page->submit_body_item = nullptr;
- return result;
+ return page->submit(args, result_tabs);
}
void MangaCombinedSearchPage::cancel_operation() {
diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp
index e8d8992..609dab9 100644
--- a/src/plugins/MangaGeneric.cpp
+++ b/src/plugins/MangaGeneric.cpp
@@ -284,7 +284,7 @@ namespace QuickMedia {
}
}
- PluginResult MangaGenericSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult MangaGenericSearchPage::submit(const SubmitArgs &submit_args, std::vector<Tab> &result_tabs) {
if(!list_chapters_query.html_query || !list_chapters_query.title_field || !list_chapters_query.url_field) {
assert(false);
return PluginResult::ERR;
@@ -303,7 +303,7 @@ namespace QuickMedia {
search_userdata.field2_contains = list_chapters_query.url_contains;
std::string website_data;
- if(download_to_string(url, website_data, args, true, fail_on_http_error) != DownloadResult::OK)
+ if(download_to_string(submit_args.url, website_data, args, true, fail_on_http_error) != DownloadResult::OK)
return PluginResult::NET_ERR;
QuickMediaHtmlSearch html_search;
@@ -366,7 +366,7 @@ namespace QuickMedia {
auto body = create_body();
body->set_items(std::move(chapters_items));
- auto chapters_page = std::make_unique<MangaGenericChaptersPage>(program, title, url, submit_body_item->thumbnail_url, manga_id_extractor, service_name, website_url, &list_page_query, fail_on_http_error);
+ auto chapters_page = std::make_unique<MangaGenericChaptersPage>(program, submit_args.title, submit_args.url, submit_args.thumbnail_url, manga_id_extractor, service_name, website_url, &list_page_query, fail_on_http_error);
result_tabs.push_back(Tab{std::move(body), std::move(chapters_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
for(auto &it : creators) {
@@ -379,8 +379,8 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult MangaGenericChaptersPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MangaGenericImagesPage>(program, content_title, title, url, service_name, website_url, list_page_query, fail_on_http_error, thumbnail_url), nullptr});
+ PluginResult MangaGenericChaptersPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MangaGenericImagesPage>(program, content_title, args.title, args.url, service_name, website_url, list_page_query, fail_on_http_error, thumbnail_url), nullptr});
return PluginResult::OK;
}
@@ -405,11 +405,8 @@ namespace QuickMedia {
return true;
}
- PluginResult MangaGenericCreatorPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- search_page->submit_body_item = submit_body_item;
- PluginResult result = search_page->submit(title, url, result_tabs);
- search_page->submit_body_item = nullptr;
- return result;
+ PluginResult MangaGenericCreatorPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ return search_page->submit(args, result_tabs);
}
PluginResult MangaGenericCreatorPage::lazy_fetch(BodyItems &result_items) {
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 79341bd..3b6b2e0 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -350,21 +350,21 @@ namespace QuickMedia {
}
// TODO: Do requests in parallel
- PluginResult MangadexSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult MangadexSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
PluginResult result;
BodyItems body_items;
- result = get_chapters_for_manga(this, url, 0, body_items);
+ result = get_chapters_for_manga(this, args.url, 0, body_items);
if(result != PluginResult::OK)
return result;
auto body = create_body();
body->set_items(std::move(body_items));
- auto chapters_page = std::make_unique<MangadexChaptersPage>(program, this, title, url, submit_body_item->thumbnail_url);
+ auto chapters_page = std::make_unique<MangadexChaptersPage>(program, this, args.title, args.url, args.thumbnail_url);
result_tabs.push_back(Tab{std::move(body), std::move(chapters_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
std::vector<Creator> creators;
- result = get_creators_for_manga(this, url, creators);
+ result = get_creators_for_manga(this, args.url, creators);
if(result != PluginResult::OK)
return result;
@@ -376,8 +376,8 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult MangadexChaptersPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MangadexImagesPage>(program, search_page, content_title, url, title, thumbnail_url), nullptr});
+ PluginResult MangadexChaptersPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MangadexImagesPage>(program, search_page, content_title, args.url, args.title, thumbnail_url), nullptr});
return PluginResult::OK;
}
@@ -385,11 +385,8 @@ namespace QuickMedia {
return get_chapters_for_manga(this, content_url, page, result_items);
}
- PluginResult MangadexCreatorPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- search_page->submit_body_item = submit_body_item;
- PluginResult result = search_page->submit(title, url, result_tabs);
- search_page->submit_body_item = nullptr;
- return result;
+ PluginResult MangadexCreatorPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ return search_page->submit(args, result_tabs);
}
PluginResult MangadexCreatorPage::get_page(const std::string&, int page, BodyItems &result_items) {
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp
index 55f0467..a440743 100644
--- a/src/plugins/Manganelo.cpp
+++ b/src/plugins/Manganelo.cpp
@@ -30,12 +30,12 @@ namespace QuickMedia {
return true;
}
- static PluginResult submit_manga(Page *page, const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ static PluginResult submit_manga(Page *page, const SubmitArgs &args, std::vector<Tab> &result_tabs) {
BodyItems chapters_items;
std::vector<Creator> creators;
std::string website_data;
- if(download_to_string(url, website_data, {CommandArg { "-H", "referer: https://manganelo.com/" }}, true) != DownloadResult::OK)
+ if(download_to_string(args.url, website_data, {CommandArg { "-H", "referer: https://manganelo.com/" }}, true) != DownloadResult::OK)
return PluginResult::NET_ERR;
QuickMediaHtmlSearch html_search;
@@ -95,7 +95,7 @@ namespace QuickMedia {
auto chapters_body = page->create_body();
chapters_body->set_items(std::move(chapters_items));
- auto chapters_page = std::make_unique<ManganeloChaptersPage>(page->program, title, url, page->submit_body_item->thumbnail_url);
+ auto chapters_page = std::make_unique<ManganeloChaptersPage>(page->program, args.title, args.url, args.thumbnail_url);
result_tabs.push_back(Tab{std::move(chapters_body), std::move(chapters_page), page->create_search_bar("Search...", SEARCH_DELAY_FILTER)});
// TODO: Fix. Doesn't work because manganelo changed creator url format
@@ -149,12 +149,12 @@ namespace QuickMedia {
return SearchResult::OK;
}
- PluginResult ManganeloSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- return submit_manga(this, title, url, result_tabs);
+ PluginResult ManganeloSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ return submit_manga(this, args, result_tabs);
}
- PluginResult ManganeloChaptersPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<ManganeloImagesPage>(program, content_title, title, url, thumbnail_url), nullptr});
+ PluginResult ManganeloChaptersPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<ManganeloImagesPage>(program, content_title, args.title, args.url, thumbnail_url), nullptr});
return PluginResult::OK;
}
@@ -191,8 +191,8 @@ namespace QuickMedia {
}
}
- PluginResult ManganeloCreatorPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- return submit_manga(this, title, url, result_tabs);
+ PluginResult ManganeloCreatorPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ return submit_manga(this, args, result_tabs);
}
PluginResult ManganeloCreatorPage::lazy_fetch(BodyItems &result_items) {
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index c69a6df..a71b3a8 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -668,8 +668,8 @@ namespace QuickMedia {
room_tags_page->set_current_rooms_page(nullptr);
}
- PluginResult MatrixRoomsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MatrixChatPage>(program, url, this), nullptr});
+ PluginResult MatrixRoomsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MatrixChatPage>(program, args.url, this), nullptr});
return PluginResult::OK;
}
@@ -735,10 +735,10 @@ namespace QuickMedia {
current_chat_page->should_clear_data = true;
}
- PluginResult MatrixRoomTagsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult MatrixRoomTagsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
auto body = create_body(true);
Body *body_ptr = body.get();
- TagData &tag_data = tag_body_items_by_name[url];
+ TagData &tag_data = tag_body_items_by_name[args.url];
BodyItems room_body_items = tag_data.room_body_items;
sort_room_body_items(room_body_items);
body->set_items(std::move(room_body_items));
@@ -834,15 +834,15 @@ namespace QuickMedia {
}
- PluginResult MatrixInvitesPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult MatrixInvitesPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
auto body = create_body();
body->append_item(BodyItem::create("Accept"));
body->append_item(BodyItem::create("Decline"));
- result_tabs.push_back(Tab{std::move(body), std::make_unique<MatrixInviteDetailsPage>(program, matrix, this, url, "Invite to " + title), nullptr});
+ result_tabs.push_back(Tab{std::move(body), std::make_unique<MatrixInviteDetailsPage>(program, matrix, this, args.url, "Invite to " + title), nullptr});
return PluginResult::OK;
}
- PluginResult MatrixInviteDetailsPage::submit(const std::string &title, const std::string&, std::vector<Tab>&) {
+ PluginResult MatrixInviteDetailsPage::submit(const SubmitArgs &args, std::vector<Tab>&) {
if(title == "Accept") {
if(matrix->join_room(room_id) == PluginResult::OK) {
// TODO: Wait for room invite list change from the server instead of removing room here.
@@ -982,8 +982,8 @@ namespace QuickMedia {
rooms_page->set_room_as_read(room);
}
- PluginResult MatrixRoomDirectoryPage::submit(const std::string &title, const std::string&, std::vector<Tab> &result_tabs) {
- std::string server_name = title;
+ PluginResult MatrixRoomDirectoryPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ std::string server_name = args.title;
if(strncmp(server_name.c_str(), "http://", 7) == 0)
server_name.erase(0, 7);
@@ -1017,12 +1017,12 @@ namespace QuickMedia {
return plugin_result_to_search_result(lazy_fetch(result_items));
}
- PluginResult MatrixServerRoomListPage::submit(const std::string &title, const std::string &url, std::vector<Tab>&) {
- if(matrix->join_room(url) == PluginResult::OK) {
- show_notification("QuickMedia", "You joined " + title, Urgency::NORMAL);
+ PluginResult MatrixServerRoomListPage::submit(const SubmitArgs &args, std::vector<Tab>&) {
+ if(matrix->join_room(args.url) == PluginResult::OK) {
+ show_notification("QuickMedia", "You joined " + args.title, Urgency::NORMAL);
program->set_go_to_previous_page();
} else {
- show_notification("QuickMedia", "Failed to join " + title, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to join " + args.title, Urgency::CRITICAL);
}
return PluginResult::OK;
}
@@ -1060,7 +1060,7 @@ namespace QuickMedia {
MatrixNotificationsPage::MatrixNotificationsPage(Program *program, Matrix *matrix, Body *notifications_body, MatrixRoomsPage *all_rooms_page) :
LazyFetchPage(program), matrix(matrix), notifications_body(notifications_body), all_rooms_page(all_rooms_page) {}
- PluginResult MatrixNotificationsPage::submit(const std::string&, const std::string&, std::vector<Tab> &result_tabs) {
+ PluginResult MatrixNotificationsPage::submit(const SubmitArgs&, std::vector<Tab> &result_tabs) {
BodyItem *selected_item = notifications_body->get_selected();
if(!selected_item)
return PluginResult::OK;
@@ -1145,8 +1145,8 @@ namespace QuickMedia {
return plugin_result_to_search_result(matrix->search_user(str, 20, result_items));
}
- PluginResult MatrixInviteUserPage::submit(const std::string&, const std::string &url, std::vector<Tab>&) {
- PluginResult result = matrix->invite_user(room_id, url);
+ PluginResult MatrixInviteUserPage::submit(const SubmitArgs &args, std::vector<Tab>&) {
+ PluginResult result = matrix->invite_user(room_id, args.url);
if(result != PluginResult::OK) return result;
program->set_go_to_previous_page();
return PluginResult::OK;
diff --git a/src/plugins/MediaGeneric.cpp b/src/plugins/MediaGeneric.cpp
index 2b88fdb..0b69556 100644
--- a/src/plugins/MediaGeneric.cpp
+++ b/src/plugins/MediaGeneric.cpp
@@ -138,8 +138,8 @@ namespace QuickMedia {
return fetch_page_results(url, website_url, text_queries, thumbnail_queries, thumbnail_max_size, nullptr, result_items, cloudflare_bypass, extra_commands);
}
- PluginResult MediaGenericSearchPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MediaGenericVideoPage>(program, this, url), nullptr});
+ PluginResult MediaGenericSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MediaGenericVideoPage>(program, this, args.url), nullptr});
return PluginResult::OK;
}
@@ -182,8 +182,8 @@ namespace QuickMedia {
return *this;
}
- PluginResult MediaGenericRelatedPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<MediaGenericVideoPage>(program, search_page, url), nullptr});
+ PluginResult MediaGenericRelatedPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<MediaGenericVideoPage>(program, search_page, args.url), nullptr});
return PluginResult::OK;
}
diff --git a/src/plugins/MyAnimeList.cpp b/src/plugins/MyAnimeList.cpp
index ee5d4fd..b982e3c 100644
--- a/src/plugins/MyAnimeList.cpp
+++ b/src/plugins/MyAnimeList.cpp
@@ -150,16 +150,16 @@ namespace QuickMedia {
return SearchResult::OK;
}
- PluginResult MyAnimeListSearchPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult MyAnimeListSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- result_tabs.push_back({ create_body(), std::make_unique<MyAnimeListDetailsPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(false, true), std::make_unique<MyAnimeListRecommendationsPage>(program, url), nullptr });
+ result_tabs.push_back({ create_body(), std::make_unique<MyAnimeListDetailsPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(false, true), std::make_unique<MyAnimeListRecommendationsPage>(program, args.url), nullptr });
return PluginResult::OK;
}
- PluginResult MyAnimeListDetailsPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
+ PluginResult MyAnimeListDetailsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
return PluginResult::OK;
}
@@ -210,9 +210,9 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult MyAnimeListRecommendationsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back({ create_body(), std::make_unique<MyAnimeListDetailsPage>(program, url), nullptr });
- result_tabs.push_back({ create_body(false, true), std::make_unique<MyAnimeListRecommendationsPage>(program, url), nullptr });
+ PluginResult MyAnimeListRecommendationsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back({ create_body(), std::make_unique<MyAnimeListDetailsPage>(program, args.url), nullptr });
+ result_tabs.push_back({ create_body(false, true), std::make_unique<MyAnimeListRecommendationsPage>(program, args.url), nullptr });
return PluginResult::OK;
}
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;
diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp
index c7b0bb3..26c795c 100644
--- a/src/plugins/Page.cpp
+++ b/src/plugins/Page.cpp
@@ -71,12 +71,8 @@ namespace QuickMedia {
program->set_clipboard(clipboard);
}
- PluginResult BookmarksPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- // TODO: Find a better solution to not keep the submit body item alive
- redirect_page->submit_body_item = submit_body_item;
- PluginResult result = redirect_page->submit(title, url, result_tabs);
- redirect_page->submit_body_item = nullptr;
- return result;
+ PluginResult BookmarksPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ return redirect_page->submit(args, result_tabs);
}
PluginResult BookmarksPage::lazy_fetch(BodyItems &result_items) {
diff --git a/src/plugins/Peertube.cpp b/src/plugins/Peertube.cpp
index 3e23807..a5c5865 100644
--- a/src/plugins/Peertube.cpp
+++ b/src/plugins/Peertube.cpp
@@ -15,8 +15,8 @@ namespace QuickMedia {
return "";
}
- PluginResult PeertubeInstanceSelectionPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(program, url), create_search_bar("Search...", 500)});
+ PluginResult PeertubeInstanceSelectionPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(program, args.url), create_search_bar("Search...", 500)});
return PluginResult::OK;
}
@@ -252,14 +252,14 @@ namespace QuickMedia {
return videos_request(this, url, server, search_type, result_items);
}
- PluginResult PeertubeSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- const SearchType search_type = (SearchType)(uintptr_t)submit_body_item->userdata;
+ PluginResult PeertubeSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ const SearchType search_type = (SearchType)(uintptr_t)args.userdata;
if(search_type == SearchType::VIDEO_CHANNELS) {
- result_tabs.push_back(Tab{ create_body(false, true), std::make_unique<PeertubeChannelPage>(program, server, title, url), nullptr });
+ result_tabs.push_back(Tab{ create_body(false, true), std::make_unique<PeertubeChannelPage>(program, server, args.title, args.url), nullptr });
} else if(search_type == SearchType::VIDEO_PLAYLISTS) {
- result_tabs.push_back(Tab{ create_body(false, true), std::make_unique<PeertubePlaylistPage>(program, server, title, url), nullptr });
+ result_tabs.push_back(Tab{ create_body(false, true), std::make_unique<PeertubePlaylistPage>(program, server, args.title, args.url), nullptr });
} else if(search_type == SearchType::VIDEOS) {
- result_tabs.push_back(Tab{ nullptr, std::make_unique<PeertubeVideoPage>(program, server, url, false), nullptr });
+ result_tabs.push_back(Tab{ nullptr, std::make_unique<PeertubeVideoPage>(program, server, args.url, false), nullptr });
}
return PluginResult::OK;
}
@@ -274,8 +274,8 @@ namespace QuickMedia {
return videos_request(this, url, server, PeertubeSearchPage::SearchType::VIDEOS, result_items);
}
- PluginResult PeertubeChannelPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{ nullptr, std::make_unique<PeertubeVideoPage>(program, server, url, false), nullptr });
+ PluginResult PeertubeChannelPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{ nullptr, std::make_unique<PeertubeVideoPage>(program, server, args.url, false), nullptr });
return PluginResult::OK;
}
@@ -289,8 +289,8 @@ namespace QuickMedia {
return videos_request(this, url, server, PeertubeSearchPage::SearchType::VIDEOS, result_items);
}
- PluginResult PeertubePlaylistPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{ nullptr, std::make_unique<PeertubeVideoPage>(program, server, url, true), nullptr });
+ PluginResult PeertubePlaylistPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{ nullptr, std::make_unique<PeertubeVideoPage>(program, server, args.url, true), nullptr });
return PluginResult::OK;
}
diff --git a/src/plugins/Pipe.cpp b/src/plugins/Pipe.cpp
index 4fa8cf3..fdd4958 100644
--- a/src/plugins/Pipe.cpp
+++ b/src/plugins/Pipe.cpp
@@ -4,9 +4,9 @@
#include <iostream>
namespace QuickMedia {
- PluginResult PipePage::submit(const std::string &title, const std::string &url, std::vector<Tab>&) {
- puts(!url.empty() ? url.c_str() : title.c_str());
- program->set_pipe_selected_text(!url.empty() ? url : title);
+ PluginResult PipePage::submit(const SubmitArgs &args, std::vector<Tab>&) {
+ puts(!args.url.empty() ? args.url.c_str() : args.title.c_str());
+ program->set_pipe_selected_text(!args.url.empty() ? args.url : title);
return PluginResult::OK;
}
diff --git a/src/plugins/Saucenao.cpp b/src/plugins/Saucenao.cpp
index 064bb11..6833bea 100644
--- a/src/plugins/Saucenao.cpp
+++ b/src/plugins/Saucenao.cpp
@@ -47,17 +47,17 @@ namespace QuickMedia {
}
}
- PluginResult SaucenaoPage::submit(const std::string &title, const std::string&, std::vector<Tab> &result_tabs) {
- if(!submit_body_item)
+ PluginResult SaucenaoPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(!args.extra)
return PluginResult::OK;
- SaucenaoBodyItemUrls *urls = static_cast<SaucenaoBodyItemUrls*>(submit_body_item->extra.get());
+ SaucenaoBodyItemUrls *urls = static_cast<SaucenaoBodyItemUrls*>(args.extra.get());
BodyItems body_items;
for(const std::string &url : urls->urls) {
body_items.push_back(InfoPage::add_url(url));
}
- body_items.push_back(InfoPage::add_google_search(title));
+ body_items.push_back(InfoPage::add_google_search(args.title));
auto body = create_body();
body->set_items(std::move(body_items));
diff --git a/src/plugins/Soundcloud.cpp b/src/plugins/Soundcloud.cpp
index 7f2b1f1..9da65ee 100644
--- a/src/plugins/Soundcloud.cpp
+++ b/src/plugins/Soundcloud.cpp
@@ -236,17 +236,17 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult SoundcloudPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult SoundcloudPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::ERR;
- if(url == "track") {
- SoundcloudPlaylist *playlist = static_cast<SoundcloudPlaylist*>(submit_body_item->extra.get());
+ if(args.url == "track") {
+ SoundcloudPlaylist *playlist = static_cast<SoundcloudPlaylist*>(args.extra.get());
auto body = create_body(false, true);
body->set_items(playlist->tracks);
- result_tabs.push_back(Tab{std::move(body), std::make_unique<SoundcloudPlaylistPage>(program, playlist, title), nullptr});
- } else if(url.find("/stream/users/") != std::string::npos) {
- std::string query_url = url + "?client_id=" + client_id + "&limit=20&offset=0&linked_partitioning=1&app_version=1616689516&app_locale=en";
+ result_tabs.push_back(Tab{std::move(body), std::make_unique<SoundcloudPlaylistPage>(program, playlist, args.title), nullptr});
+ } else if(args.url.find("/stream/users/") != std::string::npos) {
+ std::string query_url = args.url + "?client_id=" + client_id + "&limit=20&offset=0&linked_partitioning=1&app_version=1616689516&app_locale=en";
Json::Value json_root;
DownloadResult result = download_json(json_root, query_url, {}, true);
@@ -259,9 +259,9 @@ namespace QuickMedia {
body->set_items(std::move(body_items));
if(pr != PluginResult::OK) return pr;
- result_tabs.push_back(Tab{std::move(body), std::make_unique<SoundcloudUserPage>(program, title, url, std::move(next_href)), nullptr});
+ result_tabs.push_back(Tab{std::move(body), std::make_unique<SoundcloudUserPage>(program, args.title, args.url, std::move(next_href)), nullptr});
} else {
- std::string query_url = url + "?client_id=" + client_id;
+ std::string query_url = args.url + "?client_id=" + client_id;
Json::Value json_root;
DownloadResult result = download_json(json_root, query_url, {}, true);
@@ -276,21 +276,18 @@ namespace QuickMedia {
// TODO: Remove when youtube-dl is no longer required to download music
std::string permalink_url;
- SoundcloudTrack *track = static_cast<SoundcloudTrack*>(submit_body_item->extra.get());
+ SoundcloudTrack *track = static_cast<SoundcloudTrack*>(args.extra.get());
if(track)
permalink_url = track->permalink_url;
- result_tabs.push_back(Tab{nullptr, std::make_unique<SoundcloudAudioPage>(program, title, url_json.asString(), std::move(permalink_url)), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<SoundcloudAudioPage>(program, args.title, url_json.asString(), std::move(permalink_url)), nullptr});
}
return PluginResult::OK;
}
- PluginResult SoundcloudSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- submit_page.submit_body_item = submit_body_item;
- PluginResult result = submit_page.submit(title, url, result_tabs);
- submit_page.submit_body_item = nullptr;
- return result;
+ PluginResult SoundcloudSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ return submit_page.submit(args, result_tabs);
}
SearchResult SoundcloudSearchPage::search(const std::string &str, BodyItems &result_items) {
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index b86112d..d6035f2 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -854,26 +854,26 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult YoutubeSearchPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- if(strncmp(url.c_str(), "https://www.youtube.com/channel/", 32) == 0) {
+ if(strncmp(args.url.c_str(), "https://www.youtube.com/channel/", 32) == 0) {
// TODO: Make all pages (for all services) lazy fetch in a similar manner!
- result_tabs.push_back(Tab{create_body(false, true), std::make_unique<YoutubeChannelPage>(program, url, "", title), create_search_bar("Search...", 350)});
+ result_tabs.push_back(Tab{create_body(false, true), std::make_unique<YoutubeChannelPage>(program, args.url, "", args.title), create_search_bar("Search...", 350)});
} else {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
}
return PluginResult::OK;
}
- PluginResult YoutubeSearchPage::submit_suggestion(const std::string&, const std::string &url, BodyItems &result_items) {
+ PluginResult YoutubeSearchPage::submit_suggestion(const SubmitArgs &args, BodyItems &result_items) {
continuation_token.clear();
current_page = 0;
added_videos.clear();
search_url = "https://www.youtube.com/results?search_query=";
- search_url += url_param_encode(url);
+ search_url += url_param_encode(args.url);
std::vector<CommandArg> additional_args = {
{ "-H", "x-spf-referer: " + search_url },
@@ -1003,10 +1003,10 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeCommentsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult YoutubeCommentsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- result_tabs.push_back(Tab{create_body(), std::make_unique<YoutubeCommentRepliesPage>(program, video_url, url), nullptr});
+ result_tabs.push_back(Tab{create_body(), std::make_unique<YoutubeCommentRepliesPage>(program, video_url, args.url), nullptr});
return PluginResult::OK;
}
@@ -1332,7 +1332,7 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeCommentRepliesPage::submit(const std::string&, const std::string&, std::vector<Tab>&) {
+ PluginResult YoutubeCommentRepliesPage::submit(const SubmitArgs &args, std::vector<Tab>&) {
return PluginResult::OK;
}
@@ -1531,10 +1531,10 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeChannelPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- if(url.empty())
+ PluginResult YoutubeChannelPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ if(args.url.empty())
return PluginResult::OK;
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
return PluginResult::OK;
}
@@ -1624,8 +1624,8 @@ namespace QuickMedia {
return TrackResult::OK;
}
- PluginResult YoutubeSubscriptionsPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ PluginResult YoutubeSubscriptionsPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
return PluginResult::OK;
}
@@ -1863,8 +1863,8 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeRecommendedPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ PluginResult YoutubeRecommendedPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
return PluginResult::OK;
}
@@ -1959,8 +1959,8 @@ namespace QuickMedia {
return PluginResult::OK;
}
- PluginResult YoutubeRelatedVideosPage::submit(const std::string&, const std::string &url, std::vector<Tab> &result_tabs) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, url), nullptr});
+ PluginResult YoutubeRelatedVideosPage::submit(const SubmitArgs &args, std::vector<Tab> &result_tabs) {
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
return PluginResult::OK;
}