aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-18 19:26:23 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-18 19:26:23 +0100
commitde5fa7773f0393bfab917f8bf8606cb38ba3930e (patch)
treea0c5ec51f87948181797ccd2d3934b4a86c29a00 /plugins
parent9301f1da5cf779516131f6bd5ddfc22991601128 (diff)
Refactor watch progress (prepare for global watch progress)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/LocalAnime.hpp15
-rw-r--r--plugins/Page.hpp2
-rw-r--r--plugins/WatchProgress.hpp26
3 files changed, 31 insertions, 12 deletions
diff --git a/plugins/LocalAnime.hpp b/plugins/LocalAnime.hpp
index 4c3efaa..7fe58d9 100644
--- a/plugins/LocalAnime.hpp
+++ b/plugins/LocalAnime.hpp
@@ -1,18 +1,11 @@
#pragma once
#include "Page.hpp"
+#include "WatchProgress.hpp"
#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;
@@ -59,14 +52,14 @@ namespace QuickMedia {
class LocalAnimeVideoPage : public VideoPage {
public:
- LocalAnimeVideoPage(Program *program, std::string filepath, LocalAnimeWatchProgress watch_progress)
+ LocalAnimeVideoPage(Program *program, std::string filepath, WatchProgress 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;
+ void set_watch_progress(int64_t time_pos_sec) override;
private:
- LocalAnimeWatchProgress watch_progress;
+ WatchProgress watch_progress;
};
} \ No newline at end of file
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 2ab19b1..f5b4b3a 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -177,7 +177,7 @@ namespace QuickMedia {
virtual bool is_local() const { return false; }
- virtual void set_watch_progress(double time_pos_sec) { (void)time_pos_sec; }
+ virtual void set_watch_progress(int64_t time_pos_sec) { (void)time_pos_sec; }
protected:
std::string url;
};
diff --git a/plugins/WatchProgress.hpp b/plugins/WatchProgress.hpp
new file mode 100644
index 0000000..48f549c
--- /dev/null
+++ b/plugins/WatchProgress.hpp
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <stdint.h>
+#include <string>
+#include <unordered_map>
+
+namespace QuickMedia {
+ enum class WatchedStatus {
+ WATCHED,
+ NOT_WATCHED
+ };
+
+ struct WatchProgress {
+ int64_t time_pos_sec = 0;
+ int64_t duration_sec = 0;
+ time_t timestamp = 0;
+ std::string thumbnail_url;
+
+ double get_watch_ratio() const;
+ bool has_finished_watching() const;
+ };
+
+ bool set_watch_progress_for_plugin(const char *plugin_name, const std::string &id, int64_t time_pos_sec, int64_t duration_sec, const std::string &thumbnail_url);
+ std::unordered_map<std::string, WatchProgress> get_watch_progress_for_plugin(const char *plugin_name);
+ bool toggle_watched_for_plugin_save_to_file(const char *plugin_name, const std::string &id, int64_t duration_sec, const std::string &thumbnail_url, WatchedStatus &watched_status);
+} \ No newline at end of file