From 539d9b457c4f30ef0731a479772212e7ce8bfd7c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 30 Mar 2021 00:45:51 +0200 Subject: Remove tor option. Use torsocks instead (which is what quickmedia did anyways) --- src/QuickMedia.cpp | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index b11befe..06abf22 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -452,18 +452,17 @@ namespace QuickMedia { } static void usage() { - fprintf(stderr, "usage: QuickMedia [--tor] [--no-video] [--use-system-mpv-config] [--dir ]\n"); + fprintf(stderr, "usage: QuickMedia [--no-video] [--use-system-mpv-config] [--dir ]\n"); fprintf(stderr, "OPTIONS:\n"); fprintf(stderr, " plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, pornhub, youtube, spotify, soundcloud, nyaa.si, matrix, file-manager or pipe\n"); fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n"); - fprintf(stderr, " --tor Use tor. Disabled by default\n"); fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n"); fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n"); fprintf(stderr, " --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default\n"); fprintf(stderr, " --dir Set the start directory when using file-manager\n"); fprintf(stderr, "EXAMPLES:\n"); - fprintf(stderr, "QuickMedia manganelo\n"); - fprintf(stderr, "QuickMedia youtube --tor\n"); + fprintf(stderr, " QuickMedia manganelo\n"); + fprintf(stderr, " QuickMedia --upscale-images-always manganelo\n"); } static bool is_manga_plugin(const char *plugin_name) { @@ -526,9 +525,7 @@ namespace QuickMedia { } } - if(strcmp(argv[i], "--tor") == 0) { - use_tor = true; - } else if(strcmp(argv[i], "--no-video") == 0) { + if(strcmp(argv[i], "--no-video") == 0) { no_video = true; } else if(strcmp(argv[i], "--use-system-mpv-config") == 0) { use_system_mpv_config = true; @@ -565,11 +562,6 @@ namespace QuickMedia { return -1; } - if(use_tor && !is_program_executable_by_name("torsocks")) { - fprintf(stderr, "torsocks needs to be installed when using the --tor option\n"); - return -2; - } - if(upscale_image_action != UpscaleImageAction::NO) { if(!is_manga_plugin(plugin_name)) { fprintf(stderr, "Option --upscale-images/-upscale-images-force is only valid for manganelo, mangatown and mangadex\n"); @@ -709,8 +701,6 @@ namespace QuickMedia { } if(matrix) { - matrix->use_tor = use_tor; - if(matrix->load_cached_session() == PluginResult::OK) { current_page = PageType::CHAT; } else { @@ -718,7 +708,6 @@ namespace QuickMedia { current_page = PageType::CHAT_LOGIN; chat_login_page(); } - after_matrix_login_page(); } @@ -957,10 +946,6 @@ namespace QuickMedia { body_size = sf::Vector2f(body_width, window_size.y - search_bottom - body_padding_vertical - tab_h); } - bool Program::is_tor_enabled() { - return use_tor; - } - std::unique_ptr Program::create_body() { auto body = std::make_unique(this, loading_icon); body->thumbnail_mask_shader = &circle_mask_shader; @@ -1776,7 +1761,7 @@ namespace QuickMedia { } TaskResult download_file_result = run_task_with_loading_screen([this, &video_path, video_url]() { - return download_to_file(video_url, video_path.data, {}, use_tor, true) == DownloadResult::OK; + return download_to_file(video_url, video_path.data, {}, true) == DownloadResult::OK; }); switch(download_file_result) { case TaskResult::TRUE: { @@ -1836,7 +1821,7 @@ namespace QuickMedia { video_url_converted = video_url; } - video_player = std::make_unique(use_tor, no_video, use_system_mpv_config, resume_video, is_matrix, video_event_callback, on_window_create, resources_root, get_largest_monitor_height(disp)); + video_player = std::make_unique(no_video, use_system_mpv_config, resume_video, is_matrix, video_event_callback, on_window_create, resources_root, get_largest_monitor_height(disp)); VideoPlayer::Error err = video_player->load_video(video_url_converted.c_str(), window.getSystemHandle(), plugin_name, video_title); if(err != VideoPlayer::Error::OK) { std::string err_msg = "Failed to play url: "; @@ -2014,7 +1999,7 @@ namespace QuickMedia { if(page_changed) { current_page = PageType::VIDEO_CONTENT; - //video_player = std::make_unique(use_tor, no_video, use_system_mpv_config, true, video_event_callback, on_window_create, resources_root); + //video_player = std::make_unique(no_video, use_system_mpv_config, true, video_event_callback, on_window_create, resources_root); load_video_error_check(true); } else { XMapWindow(disp, video_player_window); @@ -2234,7 +2219,7 @@ namespace QuickMedia { // TODO: Download directly to file instead. TODO: Move to page std::string image_content; - if(download_to_string(url, image_content, extra_args, is_tor_enabled(), true) != DownloadResult::OK || image_content.size() <= 255) { + if(download_to_string(url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) { if(strcmp(images_page->get_service_name(), "manganelo") == 0) { bool try_backup_url = false; std::string new_url = url; @@ -2246,7 +2231,7 @@ 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) { + if(download_to_string(new_url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) { show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL); return true; } @@ -2674,7 +2659,7 @@ namespace QuickMedia { // TODO: Make this work with other sites than 4chan auto request_google_captcha_image = [this, &captcha_texture, &captcha_image_mutex, &navigation_stage, &captcha_sprite, &challenge_description_text](GoogleCaptchaChallengeInfo &challenge_info) { std::string payload_image_data; - DownloadResult download_image_result = download_to_string(challenge_info.payload_url, payload_image_data, {}, is_tor_enabled()); + DownloadResult download_image_result = download_to_string(challenge_info.payload_url, payload_image_data, {}); if(download_image_result == DownloadResult::OK) { std::lock_guard lock(captcha_image_mutex); sf::Image captcha_image; @@ -2711,7 +2696,7 @@ namespace QuickMedia { show_notification("QuickMedia", "Failed to get captcha challenge", Urgency::CRITICAL); navigation_stage = NavigationStage::VIEWING_COMMENTS; } - }, is_tor_enabled()); + }); }; Entry comment_input("Press i to begin writing a comment..."); @@ -2862,7 +2847,7 @@ namespace QuickMedia { if(!selected_item || selected_item->attached_content_url.empty()) { return image_data; } - if(download_to_string_cache(selected_item->attached_content_url, image_data, {}, is_tor_enabled()) != DownloadResult::OK) { + if(download_to_string_cache(selected_item->attached_content_url, image_data, {}) != DownloadResult::OK) { show_notification("QuickMedia", "Failed to download image: " + selected_item->attached_content_url, Urgency::CRITICAL); image_data.clear(); } @@ -2959,7 +2944,7 @@ namespace QuickMedia { } request_google_captcha_image(challenge_info); } - }, is_tor_enabled()); + }); } } @@ -4727,7 +4712,7 @@ namespace QuickMedia { } if(current_room && current_room->body_item && room_avatar_thumbnail_data->loading_state == LoadingState::NOT_LOADED) - AsyncImageLoader::get_instance().load_thumbnail(current_room->body_item->thumbnail_url, false, AVATAR_THUMBNAIL_SIZE, use_tor, room_avatar_thumbnail_data); + AsyncImageLoader::get_instance().load_thumbnail(current_room->body_item->thumbnail_url, false, AVATAR_THUMBNAIL_SIZE, room_avatar_thumbnail_data); if(room_avatar_thumbnail_data->loading_state == LoadingState::FINISHED_LOADING && room_avatar_thumbnail_data->image->getSize().x > 0 && room_avatar_thumbnail_data->image->getSize().y > 0) { if(!room_avatar_thumbnail_data->texture.loadFromImage(*room_avatar_thumbnail_data->image)) -- cgit v1.2.3