aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-07-29 05:16:57 +0200
committerdec05eba <dec05eba@protonmail.com>2021-07-29 05:16:57 +0200
commit43e7de19358f730ee18d690a993e97a5195b80c9 (patch)
treea132a8cf5784d7a62a58dc08acf9a0e062bc5539 /src
parentda9836a92ef69bb93e521985976db0322e2d5316 (diff)
Faster video loading/error when not using xxx plugin (disable ytdl)
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp6
-rw-r--r--src/StringUtils.cpp2
-rw-r--r--src/VideoPlayer.cpp10
-rw-r--r--src/plugins/Matrix.cpp2
4 files changed, 13 insertions, 7 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 6069cf9..a48234e 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1225,21 +1225,25 @@ namespace QuickMedia {
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.pornhub.com/", sf::Vector2i(320/1.5f, 180/1.5f), false);
add_pornhub_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
+ use_youtube_dl = true;
} else if(strcmp(plugin_name, "spankbang") == 0) {
check_youtube_dl_installed(plugin_name);
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://spankbang.com/", sf::Vector2i(500/2.5f, 281/2.5f), true);
add_spankbang_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
+ use_youtube_dl = true;
} else if(strcmp(plugin_name, "xvideos") == 0) {
check_youtube_dl_installed(plugin_name);
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.xvideos.com/", sf::Vector2i(352/1.5f, 198/1.5f), false);
add_xvideos_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
+ use_youtube_dl = true;
} else if(strcmp(plugin_name, "xhamster") == 0) {
check_youtube_dl_installed(plugin_name);
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://xhamster.com/", sf::Vector2i(240, 135), false);
add_xhamster_handlers(search_page.get());
tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)});
+ use_youtube_dl = true;
} else if(strcmp(plugin_name, "soundcloud") == 0) {
tabs.push_back(Tab{create_body(false, true), std::make_unique<SoundcloudSearchPage>(this), create_search_bar("Search...", 500)});
no_video = true;
@@ -2753,7 +2757,7 @@ namespace QuickMedia {
}
video_player = std::make_unique<VideoPlayer>(is_audio_only, use_system_mpv_config, is_matrix && !is_youtube, video_event_callback, on_window_create, resources_root, largest_monitor_height, plugin_name);
- VideoPlayer::Error err = video_player->load_video(v.c_str(), a.c_str(), window.getSystemHandle(), is_youtube, video_title, start_time, media_chapters);
+ VideoPlayer::Error err = video_player->load_video(v.c_str(), a.c_str(), window.getSystemHandle(), use_youtube_dl, video_title, start_time, media_chapters);
if(err != VideoPlayer::Error::OK) {
std::string err_msg = "Failed to play url: ";
err_msg += video_page->get_url();
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 96fdaeb..9820d29 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -103,7 +103,7 @@ namespace QuickMedia {
size_t str_find_case_insensitive(const std::string &str, size_t start_index, const char *substr, size_t substr_len) {
auto it = std::search(str.begin() + start_index, str.end(), substr, substr + substr_len,
[](char c1, char c2) {
- return std::toupper(c1) == std::toupper(c2);
+ return to_upper(c1) == to_upper(c2);
});
if(it == str.end())
return std::string::npos;
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 98d215d..7f01912 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -70,6 +70,7 @@ namespace QuickMedia {
no_video(no_video),
use_system_mpv_config(use_system_mpv_config),
keep_open(keep_open),
+ use_youtube_dl(true),
video_process_id(-1),
connected_to_ipc(false),
connect_tries(0),
@@ -115,7 +116,7 @@ namespace QuickMedia {
remove(tmp_chapters_filepath);
}
- VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, bool is_youtube, const std::string &title, const std::string &start_time) {
+ VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, const std::string &title, const std::string &start_time) {
parent_window = _parent_window;
if(!tmpnam(ipc_server_path)) {
@@ -166,7 +167,7 @@ namespace QuickMedia {
else
ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best";
- if(is_youtube)
+ if(!use_youtube_dl)
args.push_back("--no-ytdl");
else
args.push_back(ytdl_format.c_str());
@@ -232,17 +233,18 @@ namespace QuickMedia {
return Error::OK;
}
- VideoPlayer::Error VideoPlayer::load_video(const char *path, const char *audio_path, sf::WindowHandle _parent_window, bool is_youtube, const std::string &title, const std::string &start_time, const std::vector<MediaChapter> &chapters) {
+ VideoPlayer::Error VideoPlayer::load_video(const char *path, const char *audio_path, sf::WindowHandle _parent_window, bool use_youtube_dl, const std::string &title, const std::string &start_time, const std::vector<MediaChapter> &chapters) {
// This check is to make sure we dont change window that the video belongs to. This is not a usecase we will have so
// no need to support it for now at least.
assert(parent_window == 0 || parent_window == _parent_window);
assert(path);
+ this->use_youtube_dl = use_youtube_dl;
if(!create_tmp_file_with_chapters_data(tmp_chapters_filepath, chapters))
fprintf(stderr, "Warning: failed to create chapters file. Chapters will not be displayed\n");
fprintf(stderr, "Playing video: %s, audio: %s\n", path ? path : "", audio_path ? audio_path : "");
if(video_process_id == -1)
- return launch_video_process(path, audio_path, _parent_window, is_youtube, title, start_time);
+ return launch_video_process(path, audio_path, _parent_window, title, start_time);
// TODO: When these are used, add audio_path, title and start_time. Also handle is_youtube
Json::Value command_data(Json::arrayValue);
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 68b9524..ca211e1 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -34,7 +34,7 @@ static const char* CONTINUE_FILTER = "{\"presence\":{\"limit\":0,\"types\":[\"\"
static std::string capitalize(const std::string &str) {
if(str.size() >= 1)
- return (char)std::toupper(str[0]) + str.substr(1);
+ return QuickMedia::to_upper(str[0]) + str.substr(1);
else
return "";
}