aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-17 19:18:19 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-17 19:18:34 +0100
commit02e029ed40f801e0710b09062069e7083cd30b93 (patch)
treeb3bd567ad0c03074064d62d32a876920aa58fab4 /plugins
parentd4cd63129ae5dff8fd69525424e0f8cb9ae1a905 (diff)
Add local anime tracking. Check readme for more info about local_anime config
Diffstat (limited to 'plugins')
-rw-r--r--plugins/LocalAnime.hpp59
-rw-r--r--plugins/Page.hpp6
2 files changed, 62 insertions, 3 deletions
diff --git a/plugins/LocalAnime.hpp b/plugins/LocalAnime.hpp
index cd240d3..e768da9 100644
--- a/plugins/LocalAnime.hpp
+++ b/plugins/LocalAnime.hpp
@@ -1,13 +1,50 @@
#pragma once
#include "Page.hpp"
-
-// TODO: Progress > 90% = fully watched (because ending might have been skipped)
+#include <vector>
+#include <variant>
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<LocalAnime, LocalAnimeSeason, LocalAnimeEpisode>;
+
+ struct LocalAnimeEpisode {
+ Path path;
+ time_t modified_time_seconds;
+ };
+
+ struct LocalAnimeSeason {
+ Path path;
+ std::vector<LocalAnimeItem> episodes;
+ time_t modified_time_seconds;
+ };
+
+ struct LocalAnime {
+ Path path;
+ std::vector<LocalAnimeItem> items;
+ time_t modified_time_seconds;
+ };
+
+ enum class LocalAnimeSearchPageType {
+ DIRECTORY,
+ ANIME,
+ SEASON
+ };
+
class LocalAnimeSearchPage : public LazyFetchPage {
public:
- LocalAnimeSearchPage(Program *program) : LazyFetchPage(program) {}
+ 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<Tab> &result_tabs) override;
@@ -17,5 +54,21 @@ namespace QuickMedia {
bool reseek_to_body_item_by_url() override { return true; }
std::shared_ptr<BodyItem> 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;
};
} \ No newline at end of file
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 20d6000..2ab19b1 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -174,6 +174,10 @@ namespace QuickMedia {
virtual void mark_watched() {};
// Should not do any network request to not slow down video loading
virtual void get_subtitles(SubtitleData &subtitle_data) { (void)subtitle_data; }
+
+ virtual bool is_local() const { return false; }
+
+ virtual void set_watch_progress(double time_pos_sec) { (void)time_pos_sec; }
protected:
std::string url;
};
@@ -187,6 +191,8 @@ namespace QuickMedia {
bool reload_on_page_change() override { return true; }
const char* get_bookmark_name() const override { return redirect_page->get_bookmark_name(); }
bool is_bookmark_page() const override { return true; }
+
+ mgl::vec2i thumbnail_size = {101, 141};
private:
Page *redirect_page;
bool local_thumbnail;