From 1c1d113d987e76fc3619302902d3d101590c7f38 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 7 Nov 2020 23:20:50 +0100 Subject: Fix timestamp in copying of url for videos --- src/QuickMedia.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 3867237..7c9b348 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1607,6 +1607,15 @@ namespace QuickMedia { return TaskResult::TRUE; } + static bool video_url_supports_timestamp(const std::string &url) { + std::string dummy_id; + if(youtube_url_extract_id(url, dummy_id)) + return true; + if(url.find("pornhub.com/view_video.php") != std::string::npos) + return true; + return false; + } + #define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask)) void Program::video_content_page(VideoPage *video_page, std::string video_url, std::string video_title, bool download_if_streaming_fails) { @@ -1787,14 +1796,12 @@ namespace QuickMedia { sf::Clock cursor_hide_timer; bool is_youtube = strcmp(plugin_name, "youtube") == 0; - bool is_pornhub = strcmp(plugin_name, "pornhub") == 0; - bool supports_url_timestamp = is_youtube || is_pornhub; - auto save_video_url_to_clipboard = [&video_url_is_local, &video_url, &video_player_window, &video_player, &supports_url_timestamp]() { + auto save_video_url_to_clipboard = [&video_url_is_local, &video_url, &video_player_window, &video_player]() { if(!video_player_window || video_url_is_local) return; - if(supports_url_timestamp) { + if(video_url_supports_timestamp(video_url)) { // TODO: Remove timestamp (&t= or ?t=) from video_url double time_in_file; if(video_player->get_time_in_file(&time_in_file) != VideoPlayer::Error::OK) -- cgit v1.2.3