aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/DramaCool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/DramaCool.cpp')
-rw-r--r--src/plugins/DramaCool.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/plugins/DramaCool.cpp b/src/plugins/DramaCool.cpp
index 9b419f9..4bb1054 100644
--- a/src/plugins/DramaCool.cpp
+++ b/src/plugins/DramaCool.cpp
@@ -2,6 +2,7 @@
#include "../../include/Theme.hpp"
#include "../../include/StringUtils.hpp"
#include "../../include/M3U8.hpp"
+#include "../../plugins/utils/WatchProgress.hpp"
#include <json/value.h>
#include <quickmedia/HtmlSearch.h>
@@ -118,7 +119,7 @@ namespace QuickMedia {
auto body = create_body();
body->set_items(std::move(result_items));
- result_tabs.push_back(Tab{ std::move(body), std::make_unique<DramaCoolEpisodesPage>(program), create_search_bar("Search...", SEARCH_DELAY_FILTER) });
+ result_tabs.push_back(Tab{ std::move(body), std::make_unique<DramaCoolEpisodesPage>(program, args.title), create_search_bar("Search...", SEARCH_DELAY_FILTER) });
return PluginResult::OK;
}
@@ -395,13 +396,13 @@ namespace QuickMedia {
}
*/
- result_tabs.push_back(Tab{ nullptr, std::make_unique<DramaCoolVideoPage>(program, std::move(video_url), args.title, std::move(referer)), nullptr });
+ result_tabs.push_back(Tab{ nullptr, std::make_unique<DramaCoolVideoPage>(program, std::move(video_url), series_name, args.title, std::move(referer)), nullptr });
return PluginResult::OK;
}
PluginResult DramaCoolVideoPage::load(const SubmitArgs&, VideoInfo &video_info, std::string &err_str) {
- video_info.title = title;
+ video_info.title = episode_name;
video_info.channel_url.clear();
video_info.duration = 0.0;
video_info.chapters.clear();
@@ -409,4 +410,29 @@ namespace QuickMedia {
err_str.clear();
return PluginResult::OK;
}
+
+ std::string DramaCoolVideoPage::get_url_timestamp() {
+ // TODO: Remove very old videos, to not make this file too large which slows this down on slow harddrives
+ std::unordered_map<std::string, WatchProgress> watch_progress = get_watch_progress_for_plugin("dramacool");
+ auto it = watch_progress.find(get_video_id());
+ if(it == watch_progress.end())
+ return "";
+
+ // If we are very close to the end then start from the beginning.
+ // This is the same behavior as mpv.
+ // This is better because we dont want the video player to stop immediately after we start playing and we dont get any chance to seek.
+ if(it->second.time_pos_sec + 10.0 >= it->second.duration_sec)
+ return "";
+ else
+ return std::to_string(it->second.time_pos_sec);
+ }
+
+ void DramaCoolVideoPage::set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) {
+ std::string video_id = get_video_id();
+ set_watch_progress_for_plugin("dramacool", video_id, time_pos_sec, duration_sec, video_id);
+ }
+
+ std::string DramaCoolVideoPage::get_video_id() const {
+ return series_name + "/" + episode_name;
+ }
} \ No newline at end of file