aboutsummaryrefslogtreecommitdiff
path: root/src/VideoPlayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r--src/VideoPlayer.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index caeaa15..2407955 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -64,8 +64,9 @@ namespace QuickMedia {
}
}
- VideoPlayer::VideoPlayer(bool no_video, bool use_system_mpv_config, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root, int monitor_height) :
+ VideoPlayer::VideoPlayer(bool no_video, bool use_system_mpv_config, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root, int monitor_height, std::string plugin_name) :
exit_status(0),
+ plugin_name(std::move(plugin_name)),
no_video(no_video),
use_system_mpv_config(use_system_mpv_config),
keep_open(keep_open),
@@ -134,12 +135,6 @@ namespace QuickMedia {
std::string input_conf = "--input-conf=" + resource_root + "input.conf";
- std::string ytdl_format;
- if(no_video)
- ytdl_format = "--ytdl-format=bestaudio/best";
- else
- ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best";
-
// TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched
args.insert(args.end(), {
"mpv",
@@ -148,7 +143,6 @@ namespace QuickMedia {
"--no-terminal",
"--save-position-on-quit=no",
"--profile=pseudo-gui", // For gui when playing audio, requires a version of mpv that isn't ancient
- ytdl_format.c_str(),
"--no-resume-playback",
// TODO: Disable hr seek on low power devices?
"--hr-seek=yes",
@@ -168,8 +162,27 @@ namespace QuickMedia {
if(keep_open)
args.push_back("--keep-open=yes");
+ Path cookies_filepath;
+ std::string cookies_arg;
+ if(get_cookies_filepath(cookies_filepath, is_youtube ? "youtube" : plugin_name) == 0) {
+ cookies_arg = "--cookies-file=";
+ cookies_arg += cookies_filepath.data;
+ args.push_back("--cookies");
+ args.push_back(cookies_arg.c_str());
+ } else {
+ fprintf(stderr, "Failed to create %s cookies filepath\n", is_youtube ? "youtube" : plugin_name.c_str());
+ }
+
+ std::string ytdl_format;
+ if(no_video)
+ ytdl_format = "--ytdl-format=bestaudio/best";
+ else
+ ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best";
+
if(is_youtube)
args.push_back("--no-ytdl");
+ else
+ args.push_back(ytdl_format.c_str());
if(!use_system_mpv_config) {
args.insert(args.end(), {