aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Manganelo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Manganelo.cpp')
-rw-r--r--src/plugins/Manganelo.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp
index a97f75a..89f882c 100644
--- a/src/plugins/Manganelo.cpp
+++ b/src/plugins/Manganelo.cpp
@@ -1,4 +1,5 @@
#include "../../plugins/Manganelo.hpp"
+#include "../../include/Notification.hpp"
#include <quickmedia/HtmlSearch.h>
#include <json/reader.h>
@@ -159,4 +160,37 @@ namespace QuickMedia {
}
return ImageResult::OK;
}
+
+ bool Manganelo::extract_id_from_url(const std::string &url, std::string &manga_id) {
+ bool manganelo_website = false;
+ if(url.find("mangakakalot") != std::string::npos || url.find("manganelo") != std::string::npos)
+ manganelo_website = true;
+
+ if(manganelo_website) {
+ size_t index = url.find("manga/");
+ if(index == std::string::npos) {
+ std::string err_msg = "Url ";
+ err_msg += url;
+ err_msg += " doesn't contain manga id";
+ show_notification("Manga", err_msg, Urgency::CRITICAL);
+ return false;
+ }
+
+ manga_id = url.substr(index + 6);
+ if(manga_id.size() <= 2) {
+ std::string err_msg = "Url ";
+ err_msg += url;
+ err_msg += " doesn't contain manga id";
+ show_notification("Manga", err_msg, Urgency::CRITICAL);
+ return false;
+ }
+ return true;
+ } else {
+ std::string err_msg = "Unexpected url ";
+ err_msg += url;
+ err_msg += " is not manganelo or mangakakalot";
+ show_notification("Manga", err_msg, Urgency::CRITICAL);
+ return false;
+ }
+ }
} \ No newline at end of file