aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md15
-rw-r--r--include/QuickMedia.hpp2
-rw-r--r--src/QuickMedia.cpp47
3 files changed, 43 insertions, 21 deletions
diff --git a/README.md b/README.md
index fec9525..2c78d11 100644
--- a/README.md
+++ b/README.md
@@ -7,13 +7,14 @@ Cache is stored under `$XDG_CACHE_HOME/quickmedia` or `$HOME/.cache/quickmedia`.
```
usage: quickmedia [plugin] [--dir <directory>] [-e <window>] [youtube-url]
OPTIONS:
- 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 or stdin
- --no-video Only play audio when playing a video. Disabled by default
- --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default
- --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default
- --dir <directory> Set the start directory when using file-manager
- --instance <instance> The instance to use for peertube
- -e <window> Embed QuickMedia into another window
+ 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 or stdin
+ --no-video Only play audio when playing a video. Disabled by default
+ --upscale-images Upscale low-resolution manga pages using waifu2x-ncnn-vulkan. Disabled by default
+ --upscale-images-always Upscale manga pages using waifu2x-ncnn-vulkan, no matter what the original image resolution is. Disabled by default
+ --dir <directory> Set the start directory when using file-manager
+ --instance <instance> The instance to use for peertube
+ -e <window-id> Embed QuickMedia into another window
+ --video-max-height <height> Media plugins will try to select a video source that is this size or smaller
EXAMPLES:
quickmedia
quickmedia --upscale-images-always manganelo
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 19c634e..c19e1f6 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -117,6 +117,7 @@ namespace QuickMedia {
bool page_loop(std::vector<Tab> &tabs, int start_tab_index = 0, PageLoopSubmitHandler after_submit_handler = nullptr, bool go_to_previous_on_escape = true);
void video_page_download_video(const std::string &url, sf::WindowHandle video_player_window = None);
bool video_download_if_non_streamable(std::string &video_url, std::string &audio_url, bool &is_audio_only, bool &has_embedded_audio, PageType previous_page);
+ int video_get_max_height();
void 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 = nullptr, const std::string &parent_page_search = "");
void save_manga_progress(MangaImagesPage *images_page, Json::Value &json_chapters, Json::Value &json_chapter, int &latest_read);
// Returns -1 to go to previous chapter, 0 to stay on same chapter and 1 to go to next chapter
@@ -213,5 +214,6 @@ namespace QuickMedia {
std::string youtube_url;
std::unique_ptr<VideoPlayer> video_player;
bool use_youtube_dl = false;
+ int video_max_height = 0;
};
} \ No newline at end of file
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) {