From 9301f1da5cf779516131f6bd5ddfc22991601128 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 18 Feb 2022 18:19:35 +0100 Subject: local-anime: fix broken duration (fixes watch progress) --- src/plugins/LocalAnime.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/plugins/LocalAnime.cpp b/src/plugins/LocalAnime.cpp index 318058b..9757be1 100644 --- a/src/plugins/LocalAnime.cpp +++ b/src/plugins/LocalAnime.cpp @@ -367,6 +367,19 @@ namespace QuickMedia { void LocalAnimeVideoPage::set_watch_progress(double time_pos_sec) { std::string filename_relative_to_anime_dir = url.substr(get_config().local_anime.directory.size() + 1); + FileAnalyzer file_analyzer; + if(!file_analyzer.load_file(url.c_str(), true)) { + show_notification("QuickMedia", "Failed to load " + filename_relative_to_anime_dir + " to set watch progress", Urgency::CRITICAL); + return; + } + + if(!file_analyzer.get_duration_seconds()) { + show_notification("QuickMedia", "Failed to get duration of " + filename_relative_to_anime_dir + " to set watch progress", Urgency::CRITICAL); + return; + } + + watch_progress.duration = *file_analyzer.get_duration_seconds(); + Path watch_progress_dir = get_storage_dir().join("watch-progress"); if(create_directory_recursive(watch_progress_dir) != 0) { show_notification("QuickMedia", "Failed to create " + watch_progress_dir.data + " to set watch progress for " + filename_relative_to_anime_dir, Urgency::CRITICAL); -- cgit v1.2.3