From d0f54de4520990c8465bf2b78a1ce8c0161d46d7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 17 Jun 2021 10:24:55 +0200 Subject: Properly support youtube timestamp in url --- src/QuickMedia.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 77098a3..5316d3f 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -2383,19 +2383,6 @@ namespace QuickMedia { download_async_gui(url, file_manager_start_dir.string(), true, audio_only); } - static std::string youtube_url_extract_timestamp(const std::string &url) { - size_t timestamp_start = url.find("t="); - if(timestamp_start == std::string::npos) - return ""; - - timestamp_start += 2; - size_t timestamp_end = url.find('&'); - if(timestamp_end == std::string::npos) - timestamp_end = url.size(); - - return url.substr(timestamp_start, timestamp_end - timestamp_start); - } - bool Program::video_download_if_non_streamable(std::string &video_url, std::string &audio_url, bool &is_audio_only, bool &has_embedded_audio, PageType previous_page) { Path video_cache_dir = get_cache_dir().join("media"); Path video_path = video_cache_dir; @@ -2562,8 +2549,8 @@ namespace QuickMedia { } const bool is_resume_go_back = !start_time.empty(); - if(is_youtube && start_time.empty()) - start_time = youtube_url_extract_timestamp(video_page->get_url()); + if(start_time.empty()) + start_time = video_page->get_url_timestamp(); prev_start_time = start_time; watched_videos.insert(video_page->get_url()); @@ -2665,7 +2652,6 @@ namespace QuickMedia { auto save_video_url_to_clipboard = [this, video_page]() { std::string url = video_page->get_url(); if(video_url_supports_timestamp(url)) { - // TODO: Remove timestamp (&t= or ?t=) from video_url double time_in_file = 0.0; if(video_player && (video_player->get_time_in_file(&time_in_file) != VideoPlayer::Error::OK)) time_in_file = 0.0; -- cgit v1.2.3