From e3a151d5d2a71126c275567862a0cd2d471b42bc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 4 Sep 2022 22:35:17 +0200 Subject: Dramacool: watch progress --- plugins/DramaCool.hpp | 15 +++++++++++---- plugins/EpisodeNameParser.hpp | 15 --------------- plugins/LocalAnime.hpp | 2 +- plugins/WatchProgress.hpp | 26 -------------------------- plugins/utils/EpisodeNameParser.hpp | 15 +++++++++++++++ plugins/utils/WatchProgress.hpp | 26 ++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 46 deletions(-) delete mode 100644 plugins/EpisodeNameParser.hpp delete mode 100644 plugins/WatchProgress.hpp create mode 100644 plugins/utils/EpisodeNameParser.hpp create mode 100644 plugins/utils/WatchProgress.hpp (limited to 'plugins') diff --git a/plugins/DramaCool.hpp b/plugins/DramaCool.hpp index 428e632..71fdf68 100644 --- a/plugins/DramaCool.hpp +++ b/plugins/DramaCool.hpp @@ -14,19 +14,26 @@ namespace QuickMedia { class DramaCoolEpisodesPage : public Page { public: - DramaCoolEpisodesPage(Program *program) : Page(program) {} + DramaCoolEpisodesPage(Program *program, std::string series_name) : Page(program), series_name(std::move(series_name)) {} 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; + private: + std::string series_name; }; class DramaCoolVideoPage : public VideoPage { public: - DramaCoolVideoPage(Program *program, std::string url, std::string title, std::string referer) : VideoPage(program, std::move(url), false), title(std::move(title)), referer(std::move(referer)) {} - const char* get_title() const override { return title.c_str(); } + DramaCoolVideoPage(Program *program, std::string url, std::string series_name, std::string episode_name, std::string referer) : VideoPage(program, std::move(url), false), series_name(std::move(series_name)), episode_name(std::move(episode_name)), referer(std::move(referer)) {} + const char* get_title() const override { return episode_name.c_str(); } PluginResult load(const SubmitArgs &args, VideoInfo &video_info, std::string &err_str) override; + std::string get_url_timestamp() override; + void set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) override; + private: + std::string get_video_id() const; private: - std::string title; + std::string series_name; + std::string episode_name; std::string referer; }; } diff --git a/plugins/EpisodeNameParser.hpp b/plugins/EpisodeNameParser.hpp deleted file mode 100644 index 1ec847a..0000000 --- a/plugins/EpisodeNameParser.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#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 4925767..4d51e24 100644 --- a/plugins/LocalAnime.hpp +++ b/plugins/LocalAnime.hpp @@ -1,7 +1,7 @@ #pragma once #include "Page.hpp" -#include "WatchProgress.hpp" +#include "utils/WatchProgress.hpp" #include #include diff --git a/plugins/WatchProgress.hpp b/plugins/WatchProgress.hpp deleted file mode 100644 index 48f549c..0000000 --- a/plugins/WatchProgress.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include -#include -#include - -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 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 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 +#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/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 +#include +#include + +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 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 -- cgit v1.2.3