#pragma once #include "Page.hpp" #include #include namespace QuickMedia { struct LocalAnimeWatchProgress { double time = 0.0; double duration = 0.0; double get_watch_ratio() const; bool has_finished_watching() const; }; struct LocalAnime; struct LocalAnimeSeason; struct LocalAnimeEpisode; using LocalAnimeItem = std::variant; struct LocalAnimeEpisode { Path path; time_t modified_time_seconds; }; struct LocalAnimeSeason { Path path; std::vector episodes; time_t modified_time_seconds; }; struct LocalAnime { Path path; std::vector items; time_t modified_time_seconds; }; enum class LocalAnimeSearchPageType { DIRECTORY, ANIME, SEASON }; class LocalAnimeSearchPage : public LazyFetchPage { public: LocalAnimeSearchPage(Program *program, Path directory, LocalAnimeSearchPageType type) : LazyFetchPage(program), directory(std::move(directory)), type(type) {} 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; const char* get_bookmark_name() const override { return "local-anime"; } bool reload_on_page_change() override { return true; } bool reseek_to_body_item_by_url() override { return true; } std::shared_ptr get_bookmark_body_item(BodyItem *selected_item) override; void toggle_read(BodyItem *selected_item) override; private: Path directory; LocalAnimeSearchPageType type; }; class LocalAnimeVideoPage : public VideoPage { public: LocalAnimeVideoPage(Program *program, std::string filepath, LocalAnimeWatchProgress watch_progress) : VideoPage(program, std::move(filepath)), watch_progress(std::move(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(double time_pos_sec) override; private: LocalAnimeWatchProgress watch_progress; }; }