From 2beeddb325ecbc03ddd6c741449fabd527a3c8cc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 20 Feb 2022 22:52:28 +0100 Subject: Local-anime: add option to group episodes into anime groups from the name of the anime by using the local_manga.auto_group_episodes config --- plugins/EpisodeNameParser.hpp | 15 +++++++++++++++ plugins/LocalAnime.hpp | 25 +++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 plugins/EpisodeNameParser.hpp (limited to 'plugins') diff --git a/plugins/EpisodeNameParser.hpp b/plugins/EpisodeNameParser.hpp new file mode 100644 index 0000000..1ec847a --- /dev/null +++ b/plugins/EpisodeNameParser.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace QuickMedia { + struct EpisodeNameParts { + std::string_view group; // optional + std::string_view anime; // required + std::string_view season; // optional + std::string_view episode; // required + }; + + std::optional episode_name_extract_parts(std::string_view episode_name); +} \ No newline at end of file diff --git a/plugins/LocalAnime.hpp b/plugins/LocalAnime.hpp index 7fe58d9..19b93e8 100644 --- a/plugins/LocalAnime.hpp +++ b/plugins/LocalAnime.hpp @@ -17,49 +17,42 @@ namespace QuickMedia { }; struct LocalAnimeSeason { - Path path; + std::string name; std::vector episodes; time_t modified_time_seconds; }; struct LocalAnime { - Path path; + std::string name; std::vector items; time_t modified_time_seconds; }; - enum class LocalAnimeSearchPageType { - DIRECTORY, - ANIME, - SEASON - }; + std::vector get_anime_in_directory(const Path &directory); class LocalAnimeSearchPage : public LazyFetchPage { public: - LocalAnimeSearchPage(Program *program, Path directory, LocalAnimeSearchPageType type) - : LazyFetchPage(program), directory(std::move(directory)), type(type) {} + LocalAnimeSearchPage(Program *program, std::vector anime_items) + : LazyFetchPage(program), anime_items(std::move(anime_items)) {} const char* get_title() const override { return "Search"; } bool search_is_filter() override { return true; } PluginResult submit(const SubmitArgs &args, std::vector &result_tabs) override; PluginResult lazy_fetch(BodyItems &result_items) override; - bool reload_on_page_change() override { return true; } - bool reseek_to_body_item_by_url() override { return true; } void toggle_read(BodyItem *selected_item) override; private: - Path directory; - LocalAnimeSearchPageType type; + std::vector anime_items; }; class LocalAnimeVideoPage : public VideoPage { public: - LocalAnimeVideoPage(Program *program, std::string filepath, WatchProgress watch_progress) - : VideoPage(program, std::move(filepath)), watch_progress(std::move(watch_progress)) {} + LocalAnimeVideoPage(Program *program, std::string filepath, WatchProgress *watch_progress) + : VideoPage(program, std::move(filepath)), watch_progress(watch_progress) {} const char* get_title() const override { return ""; } std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override; std::string get_url_timestamp() override; bool is_local() const override { return true; } void set_watch_progress(int64_t time_pos_sec) override; private: - WatchProgress watch_progress; + WatchProgress *watch_progress; }; } \ No newline at end of file -- cgit v1.2.3