aboutsummaryrefslogtreecommitdiff
path: root/src/VideoPlayer.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-06 08:18:38 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-06 08:18:38 +0200
commite66d24f74d5458241d869fb3df42b4f2a2ea69f4 (patch)
tree760d09d7626cf1a7cb2845c0133a125a944344a2 /src/VideoPlayer.cpp
parent12b352c31c0821ba8bd667a4ed17e1d5406fcdf6 (diff)
Show youtube recommendations instead of local recommendations from related videos
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r--src/VideoPlayer.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index a6f3640..5f860d2 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -63,7 +63,20 @@ namespace QuickMedia {
XCloseDisplay(display);
}
- VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, sf::WindowHandle _parent_window, const std::string&, const std::string&) {
+ static std::string escape_quotes(const std::string &str) {
+ std::string result;
+ for(char c : str) {
+ if(c == '"')
+ result += "\\\"";
+ else if(c == '\\')
+ result += "\\\\";
+ else
+ result += c;
+ }
+ return result;
+ }
+
+ VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, sf::WindowHandle _parent_window, const std::string &plugin_name, const std::string &) {
parent_window = _parent_window;
if(!tmpnam(ipc_server_path)) {
@@ -71,6 +84,10 @@ namespace QuickMedia {
return Error::FAIL_TO_GENERATE_IPC_FILENAME;
}
+ Path cookies_filepath;
+ if(get_cookies_filepath(cookies_filepath, plugin_name) != 0)
+ fprintf(stderr, "Failed to create %s cookies filepath\n", plugin_name.c_str());
+
const std::string parent_window_str = std::to_string(parent_window);
std::vector<const char*> args;
@@ -94,6 +111,8 @@ namespace QuickMedia {
else
ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best";
+ std::string cookies_file_arg = "--cookies-file=" + cookies_filepath.data;
+
// TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched
args.insert(args.end(), {
"mpv",
@@ -105,11 +124,12 @@ namespace QuickMedia {
cache_dir.c_str(),
watch_later_dir.c_str(),
"--cache-on-disk=yes",
- "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=",
ytdl_format.c_str(),
// TODO: Disable hr seek on low power devices?
"--hr-seek=yes",
"--gpu-context=x11egl",
+ "--cookies",
+ cookies_file_arg.c_str(),
input_conf.c_str(),
wid_arg.c_str()
});
@@ -129,18 +149,14 @@ namespace QuickMedia {
});
}
- /*
std::string ytdl_options_arg;
- if(!plugin_name.empty()) {
- Path cookies_filepath;
- if(get_cookies_filepath(cookies_filepath, plugin_name) != 0) {
- fprintf(stderr, "Warning: Failed to create %s cookies file\n", plugin_name.c_str());
- } else {
- ytdl_options_arg = "--ytdl-raw-options=cookies=" + cookies_filepath.data;
- args.push_back(ytdl_options_arg.c_str());
- }
+ if(plugin_name.empty()) {
+ ytdl_options_arg = "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=";
+ args.push_back(ytdl_options_arg.c_str());
+ } else {
+ ytdl_options_arg = "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=,mark-watched=,cookies=\"" + escape_quotes(cookies_filepath.data) + "\"";
+ args.push_back(ytdl_options_arg.c_str());
}
- */
if(no_video)
args.push_back("--no-video");