aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-24 20:31:59 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-24 20:31:59 +0100
commit8e23c088ceebd1308e0f32b584ae503495895b05 (patch)
tree879c8a3414afdbc473704ce8d718c8147c25d5cc
parentce00471fd84745dcbbcb9f2d9ef434acb3d0fd2b (diff)
Add youtube.load_progress option
-rw-r--r--example-config.json3
-rw-r--r--include/Config.hpp5
-rw-r--r--src/Config.cpp7
-rw-r--r--src/plugins/Youtube.cpp4
4 files changed, 19 insertions, 0 deletions
diff --git a/example-config.json b/example-config.json
index ce52d52..65096a3 100644
--- a/example-config.json
+++ b/example-config.json
@@ -31,6 +31,9 @@
"sort_by_name": false,
"auto_group_episodes": false
},
+ "youtube": {
+ "load_progress": true
+ },
"use_system_fonts": false,
"use_system_mpv_config": false,
"theme": "default",
diff --git a/include/Config.hpp b/include/Config.hpp
index efb7edd..dcad4f2 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -42,6 +42,10 @@ namespace QuickMedia {
bool auto_group_episodes = false;
};
+ struct YoutubeConfig {
+ bool load_progress = true;
+ };
+
struct Config {
Config() = default;
Config(const Config&) = delete;
@@ -54,6 +58,7 @@ namespace QuickMedia {
VideoConfig video;
LocalMangaConfig local_manga;
LocalAnimeConfig local_anime;
+ YoutubeConfig youtube;
bool use_system_fonts = false;
bool use_system_mpv_config = false;
std::string theme = "default";
diff --git a/src/Config.cpp b/src/Config.cpp
index a1752b1..e0f39fd 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -178,6 +178,13 @@ namespace QuickMedia {
config->local_anime.auto_group_episodes = auto_group_episodes_json.asBool();
}
+ const Json::Value &youtube_json = json_root["youtube"];
+ if(youtube_json.isObject()) {
+ const Json::Value &load_progress_json = youtube_json["load_progress"];
+ if(load_progress_json.isBool())
+ config->youtube.load_progress = load_progress_json.asBool();
+ }
+
const Json::Value &use_system_fonts_json = json_root["use_system_fonts"];
if(use_system_fonts_json.isBool())
config->use_system_fonts = use_system_fonts_json.asBool();
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index bbf3108..f8e39cf 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -7,6 +7,7 @@
#include "../../include/VideoPlayer.hpp"
#include "../../include/Utils.hpp"
#include "../../include/Theme.hpp"
+#include "../../include/Config.hpp"
#include "../../plugins/WatchProgress.hpp"
#include <optional>
#include <json/reader.h>
@@ -1863,6 +1864,9 @@ namespace QuickMedia {
if(!timestamp.empty())
return timestamp;
+ if(!get_config().youtube.load_progress)
+ return "";
+
std::string video_id;
if(!youtube_url_extract_id(url, video_id)) {
fprintf(stderr, "Failed to extract youtube id from %s\n", url.c_str());