aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-10 18:07:02 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-10 18:07:02 +0200
commit5a02e569a307293f1ec6c837335bd0a498898ed1 (patch)
treee0d7a270b9894f9431d9df4d79eae0facc6bb9e3
parentce3f65d72ffbfb6eba4fa2dea091d47e28408e55 (diff)
Make manga tracking more robust by preparing for breakage by also saving url
-rw-r--r--include/QuickMedia.hpp2
-rw-r--r--plugins/Page.hpp4
-rw-r--r--src/QuickMedia.cpp4
-rw-r--r--src/plugins/Manga.cpp2
-rw-r--r--src/plugins/Page.cpp4
5 files changed, 9 insertions, 7 deletions
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 9ca86fb..56e9d3f 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -84,7 +84,7 @@ namespace QuickMedia {
std::unique_ptr<Body> create_body(bool plain_text_list = false, bool prefer_card_view = false);
std::unique_ptr<SearchBar> create_search_bar(const std::string &placeholder, int search_delay);
- bool load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_id);
+ bool load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_url, const std::string &manga_id);
void select_file(const std::string &filepath);
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 925a53a..29fce27 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -77,7 +77,7 @@ namespace QuickMedia {
std::unique_ptr<Body> create_body(bool plain_text_list = false, bool prefer_card_view = false);
std::unique_ptr<SearchBar> create_search_bar(const std::string &placeholder_text, int search_delay);
- bool load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_id);
+ bool load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_url, const std::string &manga_id);
Program *program;
std::shared_ptr<BodyItem> submit_body_item; // TODO: Remove this
@@ -135,7 +135,7 @@ namespace QuickMedia {
virtual std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) = 0;
virtual void set_url(std::string new_url) { url = std::move(new_url); }
std::string get_url() { return url; }
- virtual std::string get_download_url(int max_height) { return url; }
+ virtual std::string get_download_url(int max_height) { (void)max_height; return url; }
// Returns empty string for no timestamp or if the video doesn't support timestamps.
// Timestamp is in seconds.
virtual std::string get_url_timestamp() { return ""; }
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index ac56f5d..258249b 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1497,7 +1497,7 @@ namespace QuickMedia {
return search_bar;
}
- bool Program::load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_id) {
+ bool Program::load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_url, const std::string &manga_id) {
Path content_storage_dir = get_storage_dir().join(service_name);
manga_id_base64 = base64_url_encode(manga_id);
content_storage_file = content_storage_dir.join(manga_id_base64);
@@ -1520,6 +1520,7 @@ namespace QuickMedia {
content_storage_json = Json::Value(Json::objectValue);
content_storage_json["name"] = manga_title;
+ content_storage_json["url"] = manga_url;
return result;
}
@@ -3550,6 +3551,7 @@ namespace QuickMedia {
}
json_chapter["current"] = std::min(latest_read, num_manga_pages);
json_chapter["total"] = num_manga_pages;
+ json_chapter["url"] = images_page->get_url();
json_chapters[images_page->get_chapter_name()] = json_chapter;
content_storage_json["chapters"] = json_chapters;
diff --git a/src/plugins/Manga.cpp b/src/plugins/Manga.cpp
index 3fa5d47..1d44bee 100644
--- a/src/plugins/Manga.cpp
+++ b/src/plugins/Manga.cpp
@@ -18,7 +18,7 @@ namespace QuickMedia {
(void)body;
std::string manga_id;
if(extract_id_from_url(content_url, manga_id))
- load_manga_content_storage(get_service_name(), content_title, manga_id);
+ load_manga_content_storage(get_service_name(), content_title, content_url, manga_id);
}
std::shared_ptr<BodyItem> MangaChaptersPage::get_bookmark_body_item() {
diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp
index b7ef30c..5ce86e6 100644
--- a/src/plugins/Page.cpp
+++ b/src/plugins/Page.cpp
@@ -39,8 +39,8 @@ namespace QuickMedia {
return program->create_search_bar(placeholder_text, search_delay);
}
- bool Page::load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_id) {
- return program->load_manga_content_storage(service_name, manga_title, manga_id);
+ bool Page::load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_url, const std::string &manga_id) {
+ return program->load_manga_content_storage(service_name, manga_title, manga_url, manga_id);
}
PluginResult BookmarksPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {