aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--example-config.json3
-rw-r--r--include/Config.hpp5
-rw-r--r--src/Config.cpp8
-rw-r--r--src/QuickMedia.cpp20
-rw-r--r--src/Theme.cpp1
6 files changed, 32 insertions, 8 deletions
diff --git a/TODO b/TODO
index e12cbb9..08ae2ee 100644
--- a/TODO
+++ b/TODO
@@ -200,4 +200,5 @@ Peertube hls streams can be really slow to start up (especially for videos.autiz
Add keybindings for image control for 4chan.
Fix youtube videos that are age restricted AND do not allow embedding. Is that even possible?
Use local lbry instead of odysee when I figure out the incorrect instructions of to use lighthouse locally.
-ffmpeg (and mpv) is very slow at playing streams (mostly affects lbry and certain peertube videos) for some reason. \ No newline at end of file
+ffmpeg (and mpv) is very slow at playing streams (mostly affects lbry and certain peertube videos) for some reason.
+Allow specifying start/end range for video/music downloads. \ No newline at end of file
diff --git a/example-config.json b/example-config.json
index 4f14a2c..cade9dd 100644
--- a/example-config.json
+++ b/example-config.json
@@ -18,6 +18,9 @@
"input": {
"font_size": 16
},
+ "video": {
+ "max_height": 2160
+ },
"use_system_fonts": false,
"use_system_mpv_config": false,
"theme": "default",
diff --git a/include/Config.hpp b/include/Config.hpp
index 5e0218b..2091cf2 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -26,6 +26,10 @@ namespace QuickMedia {
int font_size = 16;
};
+ struct VideoConfig {
+ int max_height = 0;
+ };
+
struct Config {
Config() = default;
Config(const Config&) = delete;
@@ -35,6 +39,7 @@ namespace QuickMedia {
TabConfig tab;
BodyConfig body;
InputConfig input;
+ VideoConfig video;
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 146527a..f8dc3ed 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -52,6 +52,7 @@ namespace QuickMedia {
if(config_initialized)
return;
+ setlocale(LC_ALL, "C"); // Sigh... stupid C
config_initialized = true;
// Wtf? can't use static non-pointer config because it causes a segfault when setting config.theme.
// It looks like a libc bug??? crashes for both gcc and clang.
@@ -117,6 +118,13 @@ namespace QuickMedia {
config->input.font_size = font_size_json.asDouble();
}
+ const Json::Value &video_json = json_root["video"];
+ if(video_json.isObject()) {
+ const Json::Value &max_height_json = video_json["max_height"];
+ if(max_height_json.isNumeric())
+ config->video.max_height = max_height_json.asInt();
+ }
+
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/QuickMedia.cpp b/src/QuickMedia.cpp
index 4fd76c5..9bcdcca 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2655,6 +2655,12 @@ namespace QuickMedia {
return url.find("yt_live_broadcast") != std::string::npos || url.find("manifest/") != std::string::npos;
}
+ static int video_get_max_height(Display *display) {
+ if(get_config().video.max_height > 0)
+ return get_config().video.max_height;
+ return get_largest_monitor_height(display);
+ }
+
#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
void Program::video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, Body *parent_body, int play_index, int *parent_body_page, const std::string &parent_page_search) {
@@ -2725,7 +2731,7 @@ namespace QuickMedia {
video_player_window = None;
bool is_audio_only = no_video;
- const int largest_monitor_height = get_largest_monitor_height(disp);
+ const int video_max_height = video_get_max_height(disp);
if(!reuse_media_source) {
std::string new_title;
@@ -2744,7 +2750,7 @@ namespace QuickMedia {
std::string ext;
if(!no_video)
- video_url = video_page->get_video_url(largest_monitor_height, has_embedded_audio, ext);
+ video_url = video_page->get_video_url(video_max_height, has_embedded_audio, ext);
if(video_url.empty() || no_video) {
video_url = video_page->get_audio_url(ext);
@@ -2886,7 +2892,7 @@ namespace QuickMedia {
}
}
- video_player = std::make_unique<VideoPlayer>(is_audio_only, get_config().use_system_mpv_config, is_matrix && !is_youtube, video_event_callback, on_window_create, resources_root, largest_monitor_height, plugin_name);
+ video_player = std::make_unique<VideoPlayer>(is_audio_only, get_config().use_system_mpv_config, is_matrix && !is_youtube, video_event_callback, on_window_create, resources_root, video_max_height, plugin_name);
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: ";
@@ -2966,7 +2972,7 @@ namespace QuickMedia {
sf::Clock cursor_hide_timer;
auto save_video_url_to_clipboard = [this, video_page]() {
- std::string url = video_page->get_download_url(get_largest_monitor_height(disp));
+ std::string url = video_page->get_download_url(video_get_max_height(disp));
if(video_url_supports_timestamp(url)) {
double time_in_file = 0.0;
if(video_player && (video_player->get_time_in_file(&time_in_file) != VideoPlayer::Error::OK))
@@ -3027,7 +3033,7 @@ namespace QuickMedia {
} else if(pressed_keysym == XK_f && pressing_ctrl) {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
} else if(pressed_keysym == XK_s && pressing_ctrl) {
- video_page_download_video(video_page->get_download_url(get_largest_monitor_height(disp)), video_player_window);
+ video_page_download_video(video_page->get_download_url(video_get_max_height(disp)), video_player_window);
} else if(pressed_keysym == XK_F5) {
double resume_start_time = 0.0;
video_player->get_time_in_file(&resume_start_time);
@@ -7109,7 +7115,7 @@ namespace QuickMedia {
youtube_video_page = std::make_unique<YoutubeVideoPage>(this, url);
bool cancelled = false;
bool load_successful = false;
- const int largest_monitor_height = get_largest_monitor_height(disp);
+ const int video_max_height = video_get_max_height(disp);
std::string err_str;
for(int i = 0; i < 3; ++i) {
@@ -7122,7 +7128,7 @@ namespace QuickMedia {
std::string ext;
bool has_embedded_audio = true;
- video_url = no_video ? "" : youtube_video_page->get_video_url(largest_monitor_height, has_embedded_audio, ext);
+ video_url = no_video ? "" : youtube_video_page->get_video_url(video_max_height, has_embedded_audio, ext);
audio_url.clear();
if(!has_embedded_audio || no_video)
diff --git a/src/Theme.cpp b/src/Theme.cpp
index c0702d1..90e4b30 100644
--- a/src/Theme.cpp
+++ b/src/Theme.cpp
@@ -80,6 +80,7 @@ namespace QuickMedia {
if(theme_initialized)
return;
+ setlocale(LC_ALL, "C"); // Sigh... stupid C
theme_initialized = true;
// Wtf? can't use static non-pointer config because it causes a segfault.
// It looks like a libc bug??? crashes for both gcc and clang.