aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-14 00:44:26 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-14 00:44:26 +0100
commit85629da7eea972d96c5433191fc43125811cc7a0 (patch)
tree180cc83232c66d679a3ee6630ca3f56b769cf03d /src
parente65d0b4effdbbcc9393c58075c010f59231fd45e (diff)
Remove mangadex upgrade code
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp76
-rw-r--r--src/plugins/Mangadex.cpp56
2 files changed, 0 insertions, 132 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 3ef29b5..aa86bf8 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -944,80 +944,6 @@ namespace QuickMedia {
.related_media_thumbnail_handler({{"//img", "src", "/thumb-"}});
}
- static PluginResult upgrade_legacy_mangadex_ids(Program *program, Page *page) {
- Path content_storage_dir = get_storage_dir().join("mangadex");
- if(create_directory_recursive(content_storage_dir) != 0) {
- show_notification("QuickMedia", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL);
- abort();
- }
-
- Path mangadex_upgraded = get_storage_dir().join("mangadex-upgraded");
- if(get_file_type(mangadex_upgraded) == FileType::REGULAR)
- return PluginResult::OK;
-
- show_notification("QuickMedia", "Upgrading mangadex ids", Urgency::LOW);
-
- std::vector<int> legacy_manga_ids;
- for_files_in_dir_sort_last_modified(content_storage_dir, [&legacy_manga_ids](const Path &filepath, FileType) {
- if(strcmp(filepath.ext(), ".tmp") == 0)
- return true;
-
- std::string filename = filepath.filename();
- if(filename.size() > 18) // Ignore new manga ids
- return true;
-
- std::string id_str = base64_url_decode(filename);
- char *endptr = nullptr;
- errno = 0;
- long id = strtoll(id_str.c_str(), &endptr, 10);
- if(endptr != id_str.c_str() && errno == 0)
- legacy_manga_ids.push_back(id);
- return true;
- });
-
- if(legacy_manga_ids.empty())
- return PluginResult::OK;
-
- std::vector<std::pair<int, std::string>> new_manga_ids;
- TaskResult task_result = program->run_task_with_loading_screen([page, &legacy_manga_ids, &new_manga_ids]() {
- return legacy_mangadex_id_to_new_manga_id(page, legacy_manga_ids, new_manga_ids) == PluginResult::OK;
- });
-
- if(task_result == TaskResult::TRUE) {
- if(new_manga_ids.size() != legacy_manga_ids.size()) {
- show_notification("QuickMedia", "Failed to upgrade legacy mangadex ids", Urgency::CRITICAL);
- abort();
- }
-
- for(const auto &it : new_manga_ids) {
- Path old_path = content_storage_dir;
- old_path.join(base64_url_encode(std::to_string(it.first)));
-
- Path new_path = content_storage_dir;
- new_path.join(base64_url_encode(it.second));
- if(rename_atomic(old_path.data.c_str(), new_path.data.c_str()) != 0) {
- show_notification("QuickMedia", "Failed to upgrade legacy mangadex ids", Urgency::CRITICAL);
- abort();
- }
- }
-
- if(file_overwrite_atomic(mangadex_upgraded, "1") != 0) {
- show_notification("QuickMedia", "Failed to upgrade legacy mangadex ids", Urgency::CRITICAL);
- abort();
- }
-
- show_notification("QuickMedia", "Mangadex ids upgraded", Urgency::LOW);
- return PluginResult::OK;
- } else if(task_result == TaskResult::CANCEL) {
- exit(0);
- } else if(task_result == TaskResult::FALSE) {
- show_notification("QuickMedia", "Failed to upgrade legacy mangadex ids", Urgency::CRITICAL);
- abort();
- }
-
- return PluginResult::OK;
- }
-
static void check_youtube_dl_installed(const std::string &plugin_name) {
if(!is_program_executable_by_name("youtube-dl")) {
show_notification("QuickMedia", "youtube-dl needs to be installed to play " + plugin_name + " videos", Urgency::CRITICAL);
@@ -1120,7 +1046,6 @@ namespace QuickMedia {
start_tab_index = 1;
} else if(strcmp(plugin_name, "mangadex") == 0) {
auto search_page = std::make_unique<MangadexSearchPage>(this);
- upgrade_legacy_mangadex_ids(this, search_page.get());
tabs.push_back(Tab{create_body(), std::make_unique<BookmarksPage>(this, search_page.get()), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
tabs.push_back(Tab{create_body(), std::move(search_page), create_search_bar("Search...", 400)});
@@ -1163,7 +1088,6 @@ namespace QuickMedia {
start_tab_index = 1;
} else if(strcmp(plugin_name, "manga") == 0) {
auto mangadex = std::make_unique<MangadexSearchPage>(this);
- upgrade_legacy_mangadex_ids(this, mangadex.get());
auto manganelo = std::make_unique<ManganeloSearchPage>(this);
auto manganelos = std::make_unique<MangaGenericSearchPage>(this, "manganelos", "http://manganelos.com/");
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 6aa73b0..2efd2f1 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -4,62 +4,6 @@
#include <json/writer.h>
namespace QuickMedia {
- PluginResult legacy_mangadex_id_to_new_manga_id(Page *page, const std::vector<int> &manga_ids, std::vector<std::pair<int, std::string>> &new_manga_ids) {
- Json::Value request_json(Json::objectValue);
- request_json["type"] = "manga";
- Json::Value manga_ids_json(Json::arrayValue);
- for(int manga_id : manga_ids) {
- manga_ids_json.append(manga_id);
- }
- request_json["ids"] = std::move(manga_ids_json);
-
- Json::StreamWriterBuilder json_builder;
- json_builder["commentStyle"] = "None";
- json_builder["indentation"] = "";
-
- std::vector<CommandArg> additional_args = {
- { "-X", "POST" },
- { "-H", "content-type: application/json" },
- { "--data-binary", Json::writeString(json_builder, request_json) }
- };
-
- Json::Value json_root;
- if(page->download_json(json_root, "https://api.mangadex.org/legacy/mapping", std::move(additional_args), true) != DownloadResult::OK)
- return PluginResult::NET_ERR;
-
- if(!json_root.isArray())
- return PluginResult::OK;
-
- for(const Json::Value &result_item_json : json_root) {
- if(!result_item_json.isObject())
- continue;
-
- const Json::Value &result_json = result_item_json["result"];
- if(!result_json.isString() || strcmp(result_json.asCString(), "ok") != 0)
- continue;
-
- const Json::Value &data_json = result_item_json["data"];
- if(!data_json.isObject())
- continue;
-
- const Json::Value &attributes_json = data_json["attributes"];
- if(!attributes_json.isObject())
- continue;
-
- const Json::Value &legacy_id_json = attributes_json["legacyId"];
- if(!legacy_id_json.isInt())
- continue;
-
- const Json::Value &new_id_json = attributes_json["newId"];
- if(!new_id_json.isString())
- continue;
-
- new_manga_ids.push_back(std::make_pair<int, std::string>(legacy_id_json.asInt(), new_id_json.asString()));
- }
-
- return PluginResult::OK;
- }
-
static std::string relationships_get_cover_art_filename(const Json::Value &relationships_json) {
std::string result;
if(!relationships_json.isArray())