aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp76
1 files changed, 0 insertions, 76 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/");