aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/DramaCool.hpp15
-rw-r--r--plugins/LocalAnime.hpp2
-rw-r--r--plugins/utils/EpisodeNameParser.hpp (renamed from plugins/EpisodeNameParser.hpp)0
-rw-r--r--plugins/utils/WatchProgress.hpp (renamed from plugins/WatchProgress.hpp)0
-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
9 files changed, 47 insertions, 14 deletions
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<Tab> &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/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 <vector>
#include <variant>
diff --git a/plugins/EpisodeNameParser.hpp b/plugins/utils/EpisodeNameParser.hpp
index 1ec847a..1ec847a 100644
--- a/plugins/EpisodeNameParser.hpp
+++ b/plugins/utils/EpisodeNameParser.hpp
diff --git a/plugins/WatchProgress.hpp b/plugins/utils/WatchProgress.hpp
index 48f549c..48f549c 100644
--- a/plugins/WatchProgress.hpp
+++ b/plugins/utils/WatchProgress.hpp
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 {