aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/DramaCool.cpp32
-rw-r--r--src/plugins/LocalAnime.cpp2
-rw-r--r--src/plugins/Youtube.cpp2
-rw-r--r--src/plugins/utils/EpisodeNameParser.cpp (renamed from src/plugins/EpisodeNameParser.cpp)2
-rw-r--r--src/plugins/utils/WatchProgress.cpp (renamed from src/plugins/WatchProgress.cpp)6
5 files changed, 35 insertions, 9 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
diff --git a/src/plugins/LocalAnime.cpp b/src/plugins/LocalAnime.cpp
index 1bc8ca8..6337adf 100644
--- a/src/plugins/LocalAnime.cpp
+++ b/src/plugins/LocalAnime.cpp
@@ -6,7 +6,7 @@
#include "../../include/FileAnalyzer.hpp"
#include "../../include/ResourceLoader.hpp"
#include "../../include/StringUtils.hpp"
-#include "../../plugins/EpisodeNameParser.hpp"
+#include "../../plugins/utils/EpisodeNameParser.hpp"
#include <mglpp/graphics/Rectangle.hpp>
#include <mglpp/window/Window.hpp>
#include <json/value.h>
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 93cb266..caf3a25 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -8,7 +8,7 @@
#include "../../include/Utils.hpp"
#include "../../include/Theme.hpp"
#include "../../include/Config.hpp"
-#include "../../plugins/WatchProgress.hpp"
+#include "../../plugins/utils/WatchProgress.hpp"
#include "../../include/QuickMedia.hpp"
#include <optional>
#include <json/reader.h>
diff --git a/src/plugins/EpisodeNameParser.cpp b/src/plugins/utils/EpisodeNameParser.cpp
index cbaae50..de2b8ac 100644
--- a/src/plugins/EpisodeNameParser.cpp
+++ b/src/plugins/utils/EpisodeNameParser.cpp
@@ -1,4 +1,4 @@
-#include "../../plugins/EpisodeNameParser.hpp"
+#include "../../../plugins/utils/EpisodeNameParser.hpp"
namespace QuickMedia {
static bool has_season_in_name(std::string_view episode_name) {
diff --git a/src/plugins/WatchProgress.cpp b/src/plugins/utils/WatchProgress.cpp
index db12273..805f6e7 100644
--- a/src/plugins/WatchProgress.cpp
+++ b/src/plugins/utils/WatchProgress.cpp
@@ -1,6 +1,6 @@
-#include "../../plugins/WatchProgress.hpp"
-#include "../../include/Storage.hpp"
-#include "../../include/Notification.hpp"
+#include "../../../plugins/utils/WatchProgress.hpp"
+#include "../../../include/Storage.hpp"
+#include "../../../include/Notification.hpp"
#include <json/value.h>
namespace QuickMedia {