aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 9bcdcca..3cd32e0 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -288,13 +288,14 @@ namespace QuickMedia {
static void usage() {
fprintf(stderr, "usage: quickmedia [plugin] [--no-video] [--dir <directory>] [-e <window>] [youtube-url]\n");
fprintf(stderr, "OPTIONS:\n");
- fprintf(stderr, " plugin The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, readm, onimanga, youtube, peertube, lbry, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, file-manager, stdin, pornhub, spankbang, xvideos or xhamster\n");
- fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n");
- fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n");
- fprintf(stderr, " --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default\n");
- fprintf(stderr, " --dir <directory> Set the start directory when using file-manager. Default is the the users home directory\n");
- fprintf(stderr, " --instance <instance> The instance to use for peertube\n");
- fprintf(stderr, " -e <window> Embed QuickMedia into another window\n");
+ fprintf(stderr, " plugin The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, readm, onimanga, youtube, peertube, lbry, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, file-manager, stdin, pornhub, spankbang, xvideos or xhamster\n");
+ fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n");
+ fprintf(stderr, " --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default\n");
+ fprintf(stderr, " --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default\n");
+ fprintf(stderr, " --dir <directory> Set the start directory when using file-manager. Default is the the users home directory\n");
+ fprintf(stderr, " --instance <instance> The instance to use for peertube\n");
+ fprintf(stderr, " -e <window-id> Embed QuickMedia into another window\n");
+ fprintf(stderr, " --video-max-height <height> Media plugins will try to select a video source that is this size or smaller\n");
fprintf(stderr, "EXAMPLES:\n");
fprintf(stderr, " quickmedia\n");
fprintf(stderr, " quickmedia --upscale-images-always manganelo\n");
@@ -338,6 +339,7 @@ namespace QuickMedia {
plugin_name = "launcher";
Window parent_window = None;
+ video_max_height = 0;
std::vector<Tab> tabs;
const char *url = nullptr;
std::string program_path = dirname(argv[0]);
@@ -405,7 +407,22 @@ namespace QuickMedia {
}
++i;
} else {
- fprintf(stderr, "Missing window to embed into after -e argument\n");
+ fprintf(stderr, "Missing window id after -e argument\n");
+ usage();
+ return -1;
+ }
+ } else if(strcmp(argv[i], "--video-max-height") == 0) {
+ if(i < argc - 1) {
+ errno = 0;
+ video_max_height = strtoll(argv[i + 1], nullptr, 0);
+ if(errno == EINVAL) {
+ fprintf(stderr, "Invalid --video-max-height argument. Argument has to be a number\n");
+ usage();
+ return -1;
+ }
+ ++i;
+ } else {
+ fprintf(stderr, "Missing number after --video-max-height argument\n");
usage();
return -1;
}
@@ -2655,10 +2672,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) {
+ int Program::video_get_max_height() {
+ if(video_max_height > 0)
+ return video_max_height;
if(get_config().video.max_height > 0)
return get_config().video.max_height;
- return get_largest_monitor_height(display);
+ return get_largest_monitor_height(disp);
}
#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
@@ -2731,7 +2750,7 @@ namespace QuickMedia {
video_player_window = None;
bool is_audio_only = no_video;
- const int video_max_height = video_get_max_height(disp);
+ const int video_max_height = video_get_max_height();
if(!reuse_media_source) {
std::string new_title;
@@ -2972,7 +2991,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(video_get_max_height(disp));
+ std::string url = video_page->get_download_url(video_get_max_height());
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))
@@ -3033,7 +3052,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(video_get_max_height(disp)), video_player_window);
+ video_page_download_video(video_page->get_download_url(video_get_max_height()), video_player_window);
} else if(pressed_keysym == XK_F5) {
double resume_start_time = 0.0;
video_player->get_time_in_file(&resume_start_time);
@@ -7115,7 +7134,7 @@ namespace QuickMedia {
youtube_video_page = std::make_unique<YoutubeVideoPage>(this, url);
bool cancelled = false;
bool load_successful = false;
- const int video_max_height = video_get_max_height(disp);
+ const int video_max_height = video_get_max_height();
std::string err_str;
for(int i = 0; i < 3; ++i) {