From d4cd63129ae5dff8fd69525424e0f8cb9ae1a905 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 16 Feb 2022 21:54:47 +0100 Subject: Wip: fix video duration not working for some analyzed files, get frame in middle of video instead of first frame for thumbnail --- src/plugins/LocalAnime.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/plugins/Matrix.cpp | 4 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/plugins/LocalAnime.cpp (limited to 'src/plugins') diff --git a/src/plugins/LocalAnime.cpp b/src/plugins/LocalAnime.cpp new file mode 100644 index 0000000..4bc296a --- /dev/null +++ b/src/plugins/LocalAnime.cpp @@ -0,0 +1,42 @@ +#include "../../plugins/LocalAnime.hpp" +#include "../../include/Config.hpp" +#include "../../include/Storage.hpp" +#include "../../include/Notification.hpp" + +namespace QuickMedia { + static bool validate_local_anime_dir_config_is_set() { + if(get_config().local_anime.directory.empty()) { + show_notification("QuickMedia", "local_anime.directory config is not set", Urgency::CRITICAL); + return false; + } + + if(get_file_type(get_config().local_anime.directory) != FileType::DIRECTORY) { + show_notification("QuickMedia", "local_anime.directory config is not set to a valid directory", Urgency::CRITICAL); + return false; + } + + return true; + } + + PluginResult LocalAnimeSearchPage::submit(const SubmitArgs &args, std::vector &result_tabs) { + if(!validate_local_anime_dir_config_is_set()) + return PluginResult::OK; + + return PluginResult::ERR; + } + + PluginResult LocalAnimeSearchPage::lazy_fetch(BodyItems &result_items) { + if(!validate_local_anime_dir_config_is_set()) + return PluginResult::OK; + + return PluginResult::ERR; + } + + std::shared_ptr LocalAnimeSearchPage::get_bookmark_body_item(BodyItem *selected_item) { + return nullptr; + } + + void LocalAnimeSearchPage::toggle_read(BodyItem *selected_item) { + // TODO: + } +} \ No newline at end of file diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 6b61aed..367c777 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -3690,7 +3690,7 @@ namespace QuickMedia { PluginResult Matrix::upload_file(RoomData *room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg, bool upload_thumbnail) { FileAnalyzer file_analyzer; - if(!file_analyzer.load_file(filepath.c_str())) { + if(!file_analyzer.load_file(filepath.c_str(), true)) { err_msg = "Failed to load " + filepath; return PluginResult::ERR; } @@ -3722,7 +3722,7 @@ namespace QuickMedia { char tmp_filename[] = "/tmp/quickmedia_video_frame_XXXXXX"; int tmp_file = mkstemp(tmp_filename); if(tmp_file != -1) { - if(video_get_first_frame(filepath.c_str(), tmp_filename, thumbnail_max_size.x, thumbnail_max_size.y)) { + if(video_get_first_frame(file_analyzer, tmp_filename, thumbnail_max_size.x, thumbnail_max_size.y)) { UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails. PluginResult upload_thumbnail_result = upload_file(room, tmp_filename, thumbnail_info, upload_info_ignored, err_msg, false); if(upload_thumbnail_result != PluginResult::OK) { -- cgit v1.2.3