aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-04 22:35:17 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-04 22:35:17 +0200
commite3a151d5d2a71126c275567862a0cd2d471b42bc (patch)
tree6bbfec0cf7a6bae800c96e53f4990046a450f12f /plugins/utils
parent87c8a2986d468a3fc897169c1b00fc4695e09d39 (diff)
Dramacool: watch progress
Diffstat (limited to 'plugins/utils')
-rw-r--r--plugins/utils/EpisodeNameParser.hpp15
-rw-r--r--plugins/utils/WatchProgress.hpp26
2 files changed, 41 insertions, 0 deletions
diff --git a/plugins/utils/EpisodeNameParser.hpp b/plugins/utils/EpisodeNameParser.hpp
new file mode 100644
index 0000000..1ec847a
--- /dev/null
+++ b/plugins/utils/EpisodeNameParser.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <string_view>
+#include <optional>
+
+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<EpisodeNameParts> episode_name_extract_parts(std::string_view episode_name);
+} \ No newline at end of file
diff --git a/plugins/utils/WatchProgress.hpp b/plugins/utils/WatchProgress.hpp
new file mode 100644
index 0000000..48f549c
--- /dev/null
+++ b/plugins/utils/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