aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-05-28 03:21:31 +0200
committerdec05eba <dec05eba@protonmail.com>2020-05-28 03:21:31 +0200
commit9a3e8032301840e3645ade96475a199528b19b88 (patch)
tree91e1fa638242f095e3d108c2389b226e0bd43ebd
parentfe20f4e3ce6cc194919d13460c741369d5b30c3c (diff)
Remove old unused code (mangadex html chapter list)
-rw-r--r--plugins/Mangadex.hpp1
-rw-r--r--src/plugins/Mangadex.cpp81
2 files changed, 0 insertions, 82 deletions
diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp
index 9d6d366..5feb7f8 100644
--- a/plugins/Mangadex.hpp
+++ b/plugins/Mangadex.hpp
@@ -20,7 +20,6 @@ namespace QuickMedia {
bool extract_id_from_url(const std::string &url, std::string &manga_id) override;
private:
- SearchResult search_page(const std::string &url, BodyItems &result_items, int page, bool *is_last_page);
// Caches url. If the same url is requested multiple times then the cache is used
ImageResult get_image_urls_for_chapter(const std::string &url);
private:
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 1d1730a..d17ba74 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -35,87 +35,7 @@ namespace QuickMedia {
bool *is_last_page;
};
- SearchResult Mangadex::search_page(const std::string &url, BodyItems &result_items, int page, bool *is_last_page) {
- *is_last_page = true;
- CommandArg user_agent_arg = { "-H", useragent_str };
-
- std::string chapter_url = url;
- if(chapter_url[0] != '/')
- chapter_url += "/";
- chapter_url += "chapters/" + std::to_string(page) + "/";
- std::string website_data;
- if(download_to_string(chapter_url, website_data, {std::move(user_agent_arg)}, use_tor) != DownloadResult::OK)
- return SearchResult::NET_ERR;
-
- std::string manga_id = title_url_extract_manga_id(chapter_url);
- std::string query = "//div[data-manga-id='" + manga_id + "']";
-
- BodyItemChapterContext body_item_chapter_context;
- body_item_chapter_context.body_items = &result_items;
- body_item_chapter_context.prev_chapter_number = -1;
- body_item_chapter_context.is_last_page = is_last_page;
-
- QuickMediaHtmlSearch html_search;
- int result = quickmedia_html_search_init(&html_search, website_data.c_str());
- if(result != 0)
- goto cleanup;
-
- result = quickmedia_html_find_nodes_xpath(&html_search, query.c_str(),
- [](QuickMediaHtmlNode *node, void *userdata) {
- auto *item_data = (BodyItemChapterContext*)userdata;
- const char *data_lang = quickmedia_html_node_get_attribute_value(node, "data-lang");
- if(strcmp(data_lang, language_code) != 0)
- return;
-
- const char *chapter_id = quickmedia_html_node_get_attribute_value(node, "data-id");
- if(!chapter_id)
- return;
-
- const char *chapter_number_str = quickmedia_html_node_get_attribute_value(node, "data-chapter");
- if(!chapter_number_str)
- return;
-
- int chapter_number = atoi(chapter_number_str);
- if(chapter_number == 0 || chapter_number == item_data->prev_chapter_number)
- return;
-
- item_data->prev_chapter_number = chapter_number;
-
- const char *chapter_title = quickmedia_html_node_get_attribute_value(node, "data-title");
- std::string chapter_url = mangadex_url + "/chapter/" + chapter_id;
- std::string chapter_name = std::string("Ch. ") + chapter_number_str;
- if(chapter_title)
- chapter_name += std::string(" - ") + chapter_title;
-
- auto item = std::make_unique<BodyItem>(std::move(chapter_name));
- item->url = std::move(chapter_url);
- item_data->body_items->push_back(std::move(item));
- *item_data->is_last_page = false;
- }, &body_item_chapter_context);
-
- cleanup:
- quickmedia_html_search_deinit(&html_search);
- return result == 0 ? SearchResult::OK : SearchResult::ERR;
- }
-
- // TODO: Make pagination asynchronous and make it go to the next page when navigating to the bottom in the list of chapters
- // in the GUI. Currently all pages are fetched at once, synchronously. This can be very slow for certain manga like Naruto
- // which has 21 pages of chapters...
SearchResult Mangadex::search(const std::string &url, BodyItems &result_items) {
-#if 0
- int page = 1;
- while(true) {
- bool is_last_page;
- SearchResult search_result = search_page(url, result_items, page, &is_last_page);
- if(search_result != SearchResult::OK)
- return search_result;
-
- ++page;
- if(is_last_page)
- break;
- }
- return SearchResult::OK;
-#else
CommandArg user_agent_arg = { "-H", useragent_str };
std::string manga_id = title_url_extract_manga_id(url);
@@ -193,7 +113,6 @@ namespace QuickMedia {
result_items.push_back(std::move(item));
}
return SearchResult::OK;
-#endif
}
static bool get_rememberme_token(std::string &rememberme_token) {