diff options
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r-- | src/QuickMedia.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index e374dfb..614fad3 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -766,7 +766,7 @@ namespace QuickMedia { if(create_directory_recursive(video_history_dir) != 0) { std::string err_msg = "Failed to create video history directory "; err_msg += video_history_dir.data; - show_notification("Video player", err_msg.c_str(), Urgency::CRITICAL); + show_notification("QuickMedia", err_msg.c_str(), Urgency::CRITICAL); exit(1); } @@ -798,12 +798,12 @@ namespace QuickMedia { // TOOD: Make generic, instead of checking for plugin Path content_storage_dir = get_storage_dir().join(plugin_name); if(create_directory_recursive(content_storage_dir) != 0) { - show_notification("Storage", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL); exit(1); } Path credentials_storage_dir = get_storage_dir().join("credentials"); if(create_directory_recursive(credentials_storage_dir) != 0) { - show_notification("Storage", "Failed to create directory: " + credentials_storage_dir.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to create directory: " + credentials_storage_dir.data, Urgency::CRITICAL); exit(1); } // TODO: Make asynchronous @@ -1175,9 +1175,9 @@ namespace QuickMedia { TrackResult track_result = trackable_page->track(selected_item->get_title()); // TODO: Show proper error message when this fails. For example if we are already tracking the manga if(track_result == TrackResult::OK) { - show_notification("Media tracker", "You are now tracking \"" + trackable_page->content_title + "\" after \"" + selected_item->get_title() + "\"", Urgency::LOW); + show_notification("QuickMedia", "You are now tracking \"" + trackable_page->content_title + "\" after \"" + selected_item->get_title() + "\"", Urgency::LOW); } else { - show_notification("Media tracker", "Failed to track media \"" + trackable_page->content_title + "\", chapter: \"" + selected_item->get_title() + "\"", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to track media \"" + trackable_page->content_title + "\", chapter: \"" + selected_item->get_title() + "\"", Urgency::CRITICAL); } } } @@ -1418,7 +1418,7 @@ namespace QuickMedia { std::string err_msg = "Failed to extract id of youtube url "; err_msg += video_url; err_msg + ", video wont be saved in recommendations"; - show_notification("Video player", err_msg.c_str(), Urgency::LOW); + show_notification("QuickMedia", err_msg.c_str(), Urgency::LOW); return; } @@ -1849,7 +1849,7 @@ namespace QuickMedia { return LoadImageResult::FAILED; } } else { - show_notification("Manga", "Failed to load image for page " + std::to_string(image_index + 1) + ". Image filepath: " + image_path.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to load image for page " + std::to_string(image_index + 1) + ". Image filepath: " + image_path.data, Urgency::CRITICAL); error_message = std::string("Failed to load image for page ") + std::to_string(image_index + 1); return LoadImageResult::FAILED; } @@ -1922,15 +1922,15 @@ namespace QuickMedia { if(try_backup_url) { image_content.clear(); if(download_to_string(new_url, image_content, extra_args, is_tor_enabled(), true) != DownloadResult::OK || image_content.size() <= 255) { - show_notification("Manganelo", "Failed to download image: " + new_url, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL); return false; } } else { - show_notification("Manganelo", "Failed to download image: " + url, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL); return false; } } else { - show_notification("Manga", "Failed to download image: " + url, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL); return false; } } @@ -1938,7 +1938,7 @@ namespace QuickMedia { Path image_filepath_tmp(image_filepath.data + ".tmp"); if(file_overwrite(image_filepath_tmp, image_content) != 0) { - show_notification("Storage", "Failed to save image to file: " + image_filepath_tmp.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to save image to file: " + image_filepath_tmp.data, Urgency::CRITICAL); return false; } @@ -1978,7 +1978,7 @@ namespace QuickMedia { if(rename_immediately) { if(rename(image_filepath_tmp.data.c_str(), image_filepath.data.c_str()) != 0) { perror(image_filepath_tmp.data.c_str()); - show_notification("Storage", "Failed to save image to file: " + image_filepath.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to save image to file: " + image_filepath.data, Urgency::CRITICAL); return false; } } @@ -2001,14 +2001,14 @@ namespace QuickMedia { content_cache_dir = get_cache_dir().join(images_page->get_service_name()).join(manga_id_base64).join(base64_encode(images_page->get_chapter_name())); if(create_directory_recursive(content_cache_dir) != 0) { - show_notification("Storage", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL); current_page = pop_page_stack(); return 0; } int num_images = 0; if(images_page->get_number_of_images(num_images) != ImageResult::OK) { - show_notification("Plugin", "Failed to get number of images", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to get number of images", Urgency::CRITICAL); current_page = pop_page_stack(); return 0; } @@ -2052,7 +2052,7 @@ namespace QuickMedia { json_chapter["total"] = num_images; json_chapters[images_page->get_chapter_name()] = json_chapter; if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) { - show_notification("Manga progress", "Failed to save manga progress", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to save manga progress", Urgency::CRITICAL); } bool error = !error_message.getString().isEmpty(); @@ -2206,14 +2206,14 @@ namespace QuickMedia { content_cache_dir = get_cache_dir().join(images_page->get_service_name()).join(manga_id_base64).join(base64_encode(images_page->get_chapter_name())); if(create_directory_recursive(content_cache_dir) != 0) { - show_notification("Storage", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL); current_page = pop_page_stack(); return; } int num_images = 0; if(images_page->get_number_of_images(num_images) != ImageResult::OK) { - show_notification("Plugin", "Failed to get number of images", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to get number of images", Urgency::CRITICAL); current_page = pop_page_stack(); return; } @@ -2246,7 +2246,7 @@ namespace QuickMedia { json_chapter["total"] = image_viewer.get_num_pages(); json_chapters[images_page->get_chapter_name()] = json_chapter; if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) { - show_notification("Manga progress", "Failed to save manga progress", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to save manga progress", Urgency::CRITICAL); } while(current_page == PageType::IMAGES_CONTINUOUS) { @@ -2272,7 +2272,7 @@ namespace QuickMedia { json_chapter["current"] = latest_read; json_chapters[images_page->get_chapter_name()] = json_chapter; if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) { - show_notification("Manga progress", "Failed to save manga progress", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to save manga progress", Urgency::CRITICAL); } } } @@ -2353,11 +2353,11 @@ namespace QuickMedia { captcha_sprite.setTexture(captcha_texture, true); challenge_description_text.setString(challenge_info.description); } else { - show_notification("Google captcha", "Failed to load downloaded captcha image", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to load downloaded captcha image", Urgency::CRITICAL); navigation_stage = NavigationStage::VIEWING_COMMENTS; } } else { - show_notification("Google captcha", "Failed to download captcha image", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to download captcha image", Urgency::CRITICAL); navigation_stage = NavigationStage::VIEWING_COMMENTS; } }; @@ -2378,7 +2378,7 @@ namespace QuickMedia { challenge_info = new_challenge_info.value(); request_google_captcha_image(challenge_info); } else { - show_notification("Google captcha", "Failed to get captcha challenge", Urgency::CRITICAL); + show_notification("QuickMedia", "Failed to get captcha challenge", Urgency::CRITICAL); navigation_stage = NavigationStage::VIEWING_COMMENTS; } }, is_tor_enabled()); @@ -2603,7 +2603,7 @@ namespace QuickMedia { captcha_solved_time.restart(); post_comment(); } else if(new_challenge_info) { - show_notification("Google captcha", "Failed to solve captcha, please try again"); + show_notification("QuickMedia", "Failed to solve captcha, please try again"); challenge_info = new_challenge_info.value(); navigation_stage = NavigationStage::SOLVING_POST_CAPTCHA; for(size_t i = 0; i < selected_captcha_images.size(); ++i) { @@ -3247,14 +3247,18 @@ namespace QuickMedia { video_content_page(video_page.get(), url, "No title"); redraw = true; } else { + const char *launch_program = "xdg-open"; if(!is_program_executable_by_name("xdg-open")) { - show_notification("Nyaa.si", "xdg-utils which provides xdg-open needs to be installed to download torrents", Urgency::CRITICAL); - return; + launch_program = getenv("BROWSER"); + if(!launch_program) { + show_notification("QuickMedia", "xdg-utils which provides xdg-open needs to be installed to open urls. Alternatively set the $BROWSER environment variable to a browser", Urgency::CRITICAL); + return; + } } std::string url_modified = url; if(strncmp(url.c_str(), "http://", 7) != 0 && strncmp(url.c_str(), "https://", 8) != 0) url_modified = "https://" + url; - const char *args[] = { "xdg-open", url_modified.c_str(), nullptr }; + const char *args[] = { launch_program, url_modified.c_str(), nullptr }; exec_program_async(args, nullptr); } }; |