From 1f74222bf4cfadead768b095c6b3f8d422ebf84c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 11 Feb 2022 00:42:21 +0100 Subject: Add local-manga plugin to read local manga --- include/Config.hpp | 1 + include/Path.hpp | 10 ++++++++++ include/QuickMedia.hpp | 2 +- include/Storage.hpp | 8 +++++++- include/StringUtils.hpp | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Config.hpp b/include/Config.hpp index 1a5ef10..8430e73 100644 --- a/include/Config.hpp +++ b/include/Config.hpp @@ -46,6 +46,7 @@ namespace QuickMedia { float scale = 1.0f; float font_scale = 1.0f; float spacing_scale = 1.0f; + std::string local_manga_directory; }; const Config& get_config(); diff --git a/include/Path.hpp b/include/Path.hpp index fe49265..bb08cc6 100644 --- a/include/Path.hpp +++ b/include/Path.hpp @@ -21,6 +21,7 @@ namespace QuickMedia { return *this; } + // Includes extension const char* filename() const { size_t index = data.rfind('/'); if(index == std::string::npos) @@ -28,6 +29,15 @@ namespace QuickMedia { return data.c_str() + index + 1; } + std::string filename_no_ext() const { + const char *name = filename(); + const char *extension = ext(); + if(extension[0] == '\0') + return name; + else + return data.substr(name - data.data(), extension - name); + } + // Returns empty string if no extension const char* ext() const { size_t slash_index = data.rfind('/'); diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index ce63fbb..27c6bb2 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -96,7 +96,7 @@ namespace QuickMedia { TaskResult run_task_with_loading_screen(std::function callback); const char* get_plugin_name() const; - void manga_get_watch_history(const char *plugin_name, BodyItems &history_items); + void manga_get_watch_history(const char *plugin_name, BodyItems &history_items, bool local_thumbnail); void youtube_get_watch_history(BodyItems &history_items); Json::Value load_history_json(); diff --git a/include/Storage.hpp b/include/Storage.hpp index 1bf44a9..1e38906 100644 --- a/include/Storage.hpp +++ b/include/Storage.hpp @@ -18,6 +18,11 @@ namespace QuickMedia { DIRECTORY }; + enum FileSortDirection { + ASC, + DESC + }; + Path get_home_dir(); Path get_storage_dir(); Path get_cache_dir(); @@ -30,7 +35,8 @@ namespace QuickMedia { int file_overwrite(const Path &path, const std::string &data); int file_overwrite_atomic(const Path &path, const std::string &data); void for_files_in_dir(const Path &path, FileIteratorCallback callback); - void for_files_in_dir_sort_last_modified(const Path &path, FileIteratorCallback callback); + void for_files_in_dir_sort_last_modified(const Path &path, FileIteratorCallback callback, FileSortDirection sort_dir = FileSortDirection::ASC); + void for_files_in_dir_sort_name(const Path &path, FileIteratorCallback callback, FileSortDirection sort_dir = FileSortDirection::ASC); bool read_file_as_json(const Path &filepath, Json::Value &result); bool save_json_to_file_atomic(const Path &path, const Json::Value &json); diff --git a/include/StringUtils.hpp b/include/StringUtils.hpp index d31713d..fb16d7a 100644 --- a/include/StringUtils.hpp +++ b/include/StringUtils.hpp @@ -20,6 +20,7 @@ namespace QuickMedia { bool string_starts_with(const std::string &str, const char *sub); bool string_ends_with(const std::string &str, const std::string &ends_with_str); size_t str_find_case_insensitive(const std::string &str, size_t start_index, const char *substr, size_t substr_len); + bool string_find_fuzzy_case_insensitive(const std::string &str, const std::string &substr); char to_upper(char c); bool strncase_equals(const char *str1, const char *str2, size_t length); bool strcase_equals(const char *str1, const char *str2); -- cgit v1.2.3