aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-08-25 23:34:57 +0200
committerdec05eba <dec05eba@protonmail.com>2022-08-25 23:34:57 +0200
commitdc096b888bf7cb1edaad2146ebe0588bc65ba78a (patch)
treed6a5e934bd713825cb2d2c5c0a1b616774ab52c7
parent1e3d41cc899102a4fb3aa8dad08b07bad1ad6b7c (diff)
Mangakatana: fix pages after website update
m---------depends/mglpp0
-rw-r--r--src/QuickMedia.cpp57
2 files changed, 33 insertions, 24 deletions
diff --git a/depends/mglpp b/depends/mglpp
-Subproject e97950353d4361af3faf43dd7246bae91fc09e0
+Subproject 550119dcfca055a0a09435ee71926d86bab455c
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 7c2283f..f6fe726 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -824,6 +824,33 @@ namespace QuickMedia {
.manga_id_handler("/manga/", "/");
}
+ static std::vector<std::string> get_javascript_array_string(const std::string &html_source, const std::string &var_name) {
+ std::vector<std::string> arr;
+ size_t sources_start = html_source.find(var_name + "=[");
+ if(sources_start == std::string::npos)
+ return arr;
+
+ sources_start += var_name.size() + 1; // just before [
+ size_t json_end = find_end_of_json_array(html_source.c_str(), sources_start, html_source.size());
+ if(json_end == size_t(-1))
+ return arr;
+
+ sources_start += 1;
+ json_end -= 1;
+ std::string urls_str = html_source.substr(sources_start, json_end - sources_start);
+ string_replace_all(urls_str, "'", "");
+
+ string_split(urls_str, ',', [&arr](const char *str, size_t size) {
+ std::string url(str, size);
+ url = strip(url);
+ if(!url.empty())
+ arr.push_back(std::move(url));
+ return true;
+ });
+
+ return arr;
+ }
+
static void add_mangakatana_handlers(MangaGenericSearchPage *manga_generic_search_page) {
manga_generic_search_page->search_handler("https://mangakatana.com/page/%p?search=%s&search_by=book_name", 1)
.text_handler({
@@ -842,30 +869,12 @@ namespace QuickMedia {
.list_chapters_handler("//div[class='chapters']//div[class='chapter']//a[0]", "text", "href", "/manga/")
.list_chapters_uploaded_time_handler("//div[class='chapters']//div[class='update_time']", "text", nullptr)
.list_page_images_custom_handler([](const std::string &html_source) {
- std::vector<std::string> urls;
- size_t sources_start = html_source.find("htnc=[");
- if(sources_start == std::string::npos)
- return urls;
-
- sources_start += 5; // just before [
- size_t json_end = find_end_of_json_array(html_source.c_str(), sources_start, html_source.size());
- if(json_end == size_t(-1))
- return urls;
-
- sources_start += 1;
- json_end -= 1;
- std::string urls_str = html_source.substr(sources_start, json_end - sources_start);
- string_replace_all(urls_str, "'", "");
-
- string_split(urls_str, ',', [&urls](const char *str, size_t size) {
- std::string url(str, size);
- url = strip(url);
- if(!url.empty())
- urls.push_back(std::move(url));
- return true;
- });
-
- return urls;
+ std::vector<std::string> urls_ytaw = get_javascript_array_string(html_source, "ytaw");
+ std::vector<std::string> urls_htnc = get_javascript_array_string(html_source, "htnc");
+ if(urls_ytaw.size() >= urls_htnc.size())
+ return urls_ytaw;
+ else
+ return urls_htnc;
})
.manga_id_handler("/manga/", nullptr);
}