From 522ccf3be6e17ea031a702720cea2a2e6c9f2e07 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 21 May 2021 05:48:49 +0200 Subject: Add onimanga --- src/QuickMedia.cpp | 40 ++++++++++++++++++++++++++++++++-------- src/plugins/MangaGeneric.cpp | 2 +- 2 files changed, 33 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 02a0e0f..bb9844f 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -65,6 +65,7 @@ static const std::pair valid_plugins[] = { std::make_pair("mangatown", "mangatown_logo.png"), std::make_pair("mangakatana", "mangakatana_logo.png"), std::make_pair("mangadex", "mangadex_logo.png"), + std::make_pair("onimanga", nullptr), std::make_pair("readm", "readm_logo.png"), std::make_pair("manga", nullptr), std::make_pair("youtube", "yt_logo_rgb_dark_small.png"), @@ -314,7 +315,7 @@ namespace QuickMedia { static void usage() { fprintf(stderr, "usage: quickmedia [--no-video] [--use-system-mpv-config] [--dir ] [-e ]\n"); fprintf(stderr, "OPTIONS:\n"); - fprintf(stderr, " plugin The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, readm, youtube, spotify, soundcloud, nyaa.si, matrix, saucenao, file-manager, stdin, pornhub, spankbang, xvideos or xhamster\n"); + fprintf(stderr, " plugin The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, readm, onimanga, youtube, spotify, soundcloud, nyaa.si, matrix, saucenao, file-manager, stdin, pornhub, spankbang, xvideos or xhamster\n"); fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n"); fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n"); fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n"); @@ -329,7 +330,7 @@ namespace QuickMedia { } static bool is_manga_plugin(const char *plugin_name) { - return strcmp(plugin_name, "manga") == 0 || strcmp(plugin_name, "manganelo") == 0 || strcmp(plugin_name, "manganelos") == 0 || strcmp(plugin_name, "mangatown") == 0 || strcmp(plugin_name, "mangakatana") == 0 || strcmp(plugin_name, "mangadex") == 0 || strcmp(plugin_name, "readm") == 0; + return strcmp(plugin_name, "manga") == 0 || strcmp(plugin_name, "manganelo") == 0 || strcmp(plugin_name, "manganelos") == 0 || strcmp(plugin_name, "mangatown") == 0 || strcmp(plugin_name, "mangakatana") == 0 || strcmp(plugin_name, "mangadex") == 0 || strcmp(plugin_name, "readm") == 0 || strcmp(plugin_name, "onimanga") == 0; } static std::shared_ptr create_launcher_body_item(const char *title, const char *plugin_name, const std::string &thumbnail_url) { @@ -827,6 +828,14 @@ namespace QuickMedia { .manga_id_handler("/manga/", "/"); } + static void add_onimanga_handlers(MangaGenericSearchPage *manga_generic_search_page) { + manga_generic_search_page->search_handler("https://onimanga.com/search?search=%s", 1) + .text_handler({{"//li[class='manga-name']/a", "text", "href", nullptr}}) + .list_chapters_handler("//div[class='manga-chapters']//div[class='chapter']//a", "text", "href", nullptr) + .list_page_images_handler("//img[class='page']", "src", "/scans/") + .manga_id_handler("/", nullptr); + } + static void add_pornhub_handlers(MediaGenericSearchPage *media_generic_search_page) { media_generic_search_page->search_handler("https://www.pornhub.com/video/search?search=%s&page=%p", 1) .text_handler({{"//div[class='nf-videos']//div[class='phimage']//a", "title", "href", "/view_video.php"}}) @@ -1008,6 +1017,7 @@ namespace QuickMedia { pipe_body->items.push_back(create_launcher_body_item("Manganelo", "manganelo", resources_root + "icons/manganelo_launcher.png")); pipe_body->items.push_back(create_launcher_body_item("Manganelos", "manganelos", resources_root + "icons/manganelos_launcher.png")); pipe_body->items.push_back(create_launcher_body_item("Mangatown", "mangatown", resources_root + "icons/mangatown_launcher.png")); + pipe_body->items.push_back(create_launcher_body_item("Onimanga", "onimanga", "")); pipe_body->items.push_back(create_launcher_body_item("Readm", "readm", resources_root + "icons/readm_launcher.png")); pipe_body->items.push_back(create_launcher_body_item("Matrix", "matrix", resources_root + "icons/matrix_launcher.png")); pipe_body->items.push_back(create_launcher_body_item("Nyaa.si", "nyaa.si", resources_root + "icons/nyaa_si_launcher.png")); @@ -1054,6 +1064,13 @@ namespace QuickMedia { add_readm_handlers(search_page.get()); tabs.push_back(Tab{create_body(), std::move(search_page), create_search_bar("Search...", 400)}); + auto history_page = std::make_unique(this, tabs.front().page.get(), HistoryType::MANGA); + tabs.push_back(Tab{create_body(), std::move(history_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); + } else if(strcmp(plugin_name, "onimanga") == 0) { + auto search_page = std::make_unique(this, plugin_name, "https://onimanga.com/"); + add_onimanga_handlers(search_page.get()); + tabs.push_back(Tab{create_body(), std::move(search_page), create_search_bar("Search...", 400)}); + auto history_page = std::make_unique(this, tabs.front().page.get(), HistoryType::MANGA); tabs.push_back(Tab{create_body(), std::move(history_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); } else if(strcmp(plugin_name, "manga") == 0) { @@ -1067,17 +1084,20 @@ namespace QuickMedia { add_mangatown_handlers(mangatown.get()); auto mangakatana = std::make_unique(this, "mangakatana", "https://mangakatana.com/", false); add_mangakatana_handlers(mangakatana.get()); + auto onimanga = std::make_unique(this, "onimanga", "https://onimanga.com/"); + add_onimanga_handlers(onimanga.get()); auto readm = std::make_unique(this, "readm", "https://readm.org/"); add_readm_handlers(readm.get()); // TODO: Use async task pool std::vector pages; - pages.push_back({std::move(manganelo), "Manganelo", "manganelo", resources_root + "images/" + get_plugin_logo_name("manganelo")}); - pages.push_back({std::move(manganelos), "Manganelos", "manganelos", resources_root + "images/" + get_plugin_logo_name("manganelos")}); - pages.push_back({std::move(mangatown), "Mangatown", "mangatown", resources_root + "images/" + get_plugin_logo_name("mangatown")}); - pages.push_back({std::move(mangakatana), "Mangakatana", "mangakatana", resources_root + "images/" + get_plugin_logo_name("mangakatana")}); - pages.push_back({std::move(readm), "Readm", "readm", resources_root + "images/" + get_plugin_logo_name("readm")}); - pages.push_back({std::move(mangadex), "Mangadex", "mangadex", resources_root + "images/" + get_plugin_logo_name("mangadex")}); + pages.push_back({std::move(manganelo), "Manganelo", "manganelo"}); + pages.push_back({std::move(manganelos), "Manganelos", "manganelos"}); + pages.push_back({std::move(mangatown), "Mangatown", "mangatown"}); + pages.push_back({std::move(mangakatana), "Mangakatana", "mangakatana"}); + pages.push_back({std::move(onimanga), "Onimanga", "onimanga"}); + pages.push_back({std::move(readm), "Readm", "readm"}); + pages.push_back({std::move(mangadex), "Mangadex", "mangadex"}); tabs.push_back(Tab{create_body(), std::make_unique(this, std::move(pages)), create_search_bar("Search...", 400)}); } else if(strcmp(plugin_name, "nyaa.si") == 0) { @@ -1143,6 +1163,8 @@ namespace QuickMedia { } else if(strcmp(plugin_name, "matrix") == 0) { assert(!matrix); matrix = new Matrix(); + } else { + assert(false); } } @@ -1325,6 +1347,8 @@ namespace QuickMedia { body_item->url = "https://mangatown.com/manga/" + base64_decode(filename.string()); else if(strcmp(plugin_name, "mangakatana") == 0) body_item->url = "https://mangakatana.com/manga/" + base64_decode(filename.string()); + else if(strcmp(plugin_name, "onimanga") == 0) + body_item->url = "https://onimanga.com/" + base64_decode(filename.string()); else if(strcmp(plugin_name, "readm") == 0) body_item->url = "https://readm.org/manga/" + base64_decode(filename.string()); else diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp index 2e88d60..e6fc11d 100644 --- a/src/plugins/MangaGeneric.cpp +++ b/src/plugins/MangaGeneric.cpp @@ -381,7 +381,7 @@ namespace QuickMedia { } bool MangaGenericChaptersPage::extract_id_from_url(const std::string &url, std::string &manga_id) const { - size_t start_index = url.find(manga_id_extractor.prefix); + size_t start_index = url.rfind(manga_id_extractor.prefix); if(start_index == std::string::npos) return false; -- cgit v1.2.3