From a26d0fcc0a30a28ce0e458ea275fc0787c693bc6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 8 Mar 2022 16:39:55 +0100 Subject: Save youtube watch progress and resume next time the video is played --- plugins/Lbry.hpp | 2 +- plugins/LocalAnime.hpp | 2 +- plugins/MediaGeneric.hpp | 2 +- plugins/Page.hpp | 6 +++--- plugins/Peertube.hpp | 2 +- plugins/Soundcloud.hpp | 2 +- plugins/Youtube.hpp | 6 ++++-- 7 files changed, 12 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/Lbry.hpp b/plugins/Lbry.hpp index 224e43b..d21778a 100644 --- a/plugins/Lbry.hpp +++ b/plugins/Lbry.hpp @@ -41,7 +41,7 @@ namespace QuickMedia { std::string get_download_url(int max_height) override; std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override; std::string get_audio_url(std::string &ext) override; - PluginResult load(std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str) override; + PluginResult load(std::string &title, std::string &channel_url, double &duration, std::vector &chapters, std::string &err_str) override; private: std::string title; std::string streaming_url; diff --git a/plugins/LocalAnime.hpp b/plugins/LocalAnime.hpp index 0313231..4925767 100644 --- a/plugins/LocalAnime.hpp +++ b/plugins/LocalAnime.hpp @@ -54,7 +54,7 @@ namespace QuickMedia { 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(int64_t time_pos_sec) override; + void set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) override; private: LocalAnimeSearchPage *search_page; WatchProgress *watch_progress; diff --git a/plugins/MediaGeneric.hpp b/plugins/MediaGeneric.hpp index 684f319..68ad22f 100644 --- a/plugins/MediaGeneric.hpp +++ b/plugins/MediaGeneric.hpp @@ -96,7 +96,7 @@ namespace QuickMedia { std::string get_download_url(int max_height) override; std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override; - PluginResult load(std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str) override; + PluginResult load(std::string &title, std::string &channel_url, double &duration, std::vector &chapters, std::string &err_str) override; private: MediaGenericSearchPage *search_page; std::string video_url; diff --git a/plugins/Page.hpp b/plugins/Page.hpp index e25cb84..1b8a391 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -168,8 +168,8 @@ namespace QuickMedia { virtual std::string url_get_playable_url(const std::string &url) { return url; } virtual bool video_should_be_skipped(const std::string &url) { (void)url; return false; } // This needs to be called before the other functions are called - virtual PluginResult load(std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str) { - (void)title; (void)channel_url; (void)chapters; (void)err_str; + virtual PluginResult load(std::string &title, std::string &channel_url, double &duration, std::vector &chapters, std::string &err_str) { + (void)title; (void)duration; (void)channel_url; (void)chapters; (void)err_str; return PluginResult::OK; } virtual void mark_watched() {}; @@ -178,7 +178,7 @@ namespace QuickMedia { virtual bool is_local() const { return false; } - virtual void set_watch_progress(int64_t time_pos_sec) { (void)time_pos_sec; } + virtual void set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) { (void)time_pos_sec; (void)duration_sec; } protected: std::string url; }; diff --git a/plugins/Peertube.hpp b/plugins/Peertube.hpp index 1f51555..dfd5601 100644 --- a/plugins/Peertube.hpp +++ b/plugins/Peertube.hpp @@ -81,7 +81,7 @@ namespace QuickMedia { std::string get_download_url(int max_height) override; std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override; std::string get_audio_url(std::string &ext) override; - PluginResult load(std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str) override; + PluginResult load(std::string &title, std::string &channel_url, double &duration, std::vector &chapters, std::string &err_str) override; bool autoplay_next_item() override { return autoplay_next; } //void get_subtitles(SubtitleData &subtitle_data) override; private: diff --git a/plugins/Soundcloud.hpp b/plugins/Soundcloud.hpp index 7e65cc1..0ec0ae4 100644 --- a/plugins/Soundcloud.hpp +++ b/plugins/Soundcloud.hpp @@ -60,7 +60,7 @@ namespace QuickMedia { public: SoundcloudAudioPage(Program *program, std::string title, const std::string &url, std::string permalink_url) : VideoPage(program, url), title(std::move(title)), permalink_url(std::move(permalink_url)) {} const char* get_title() const override { return ""; } - PluginResult load(std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str) override; + PluginResult load(std::string &title, std::string &channel_url, double &duration, std::vector &chapters, std::string &err_str) override; bool autoplay_next_item() override { return true; } std::string url_get_playable_url(const std::string &url) override; std::string get_download_url(int max_height) override; diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 4772aa1..8844c5b 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -29,6 +29,7 @@ namespace QuickMedia { std::string author; std::string views; std::string description; + double duration = 0.0; }; // Returns |url| if the url is already a youtube url @@ -144,12 +145,13 @@ namespace QuickMedia { PluginResult get_related_pages(const BodyItems &related_videos, const std::string &channel_url, std::vector &result_tabs) override; int get_related_pages_first_tab() override { return 1; } void set_url(std::string new_url) override; - std::string get_url_timestamp() override { return timestamp; } + std::string get_url_timestamp() override; std::string get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) override; std::string get_audio_url(std::string &ext) override; - PluginResult load(std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str) override; + PluginResult load(std::string &title, std::string &channel_url, double &duration, std::vector &chapters, std::string &err_str) override; void mark_watched() override; void get_subtitles(SubtitleData &subtitle_data) override; + void set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) override; private: PluginResult parse_video_response(const Json::Value &json_root, std::string &title, std::string &channel_url, std::vector &chapters, std::string &err_str); void parse_format(const Json::Value &format_json, bool is_adaptive); -- cgit v1.2.3