aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 6b85d34..a038f66 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -5,6 +5,7 @@
#include "../plugins/MangaCombined.hpp"
#include "../plugins/MediaGeneric.hpp"
#include "../plugins/Youtube.hpp"
+#include "../plugins/Peertube.hpp"
#include "../plugins/Fourchan.hpp"
#include "../plugins/NyaaSi.hpp"
#include "../plugins/Matrix.hpp"
@@ -72,6 +73,7 @@ static const std::pair<const char*, const char*> valid_plugins[] = {
std::make_pair("readm", "readm_logo.png"),
std::make_pair("manga", nullptr),
std::make_pair("youtube", "yt_logo_rgb_dark_small.png"),
+ std::make_pair("peertube", "peertube_logo.png"),
std::make_pair("soundcloud", "soundcloud_logo.png"),
std::make_pair("pornhub", "pornhub_logo.png"),
std::make_pair("spankbang", "spankbang_logo.png"),
@@ -281,11 +283,12 @@ 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, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, file-manager, stdin, pornhub, spankbang, xvideos or xhamster\n");
+ fprintf(stderr, " plugin The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, readm, onimanga, youtube, peertube, 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, "EXAMPLES:\n");
fprintf(stderr, " quickmedia\n");
@@ -324,6 +327,7 @@ namespace QuickMedia {
std::vector<Tab> tabs;
const char *url = nullptr;
std::string program_path = dirname(argv[0]);
+ std::string instance;
for(int i = 1; i < argc; ++i) {
if(!plugin_name) {
@@ -348,6 +352,15 @@ namespace QuickMedia {
upscale_image_action = UpscaleImageAction::LOW_RESOLUTION;
} else if(strcmp(argv[i], "--upscale-images-force") == 0 || strcmp(argv[i], "--upscale-images-always") == 0) {
upscale_image_action = UpscaleImageAction::FORCE;
+ } else if(strcmp(argv[i], "--instance") == 0) {
+ if(i < argc - 1) {
+ instance = argv[i + 1];
+ ++i;
+ } else {
+ fprintf(stderr, "Missing instance after --instance argument\n");
+ usage();
+ return -1;
+ }
} else if(strcmp(argv[i], "--dir") == 0) {
if(i < argc - 1) {
file_manager_start_dir = argv[i + 1];
@@ -475,7 +488,7 @@ namespace QuickMedia {
file_selection_handler = std::move(saucenao_file_selection_handler);
}
- load_plugin_by_name(tabs, start_tab_index, fm_mine_type, std::move(file_selection_handler));
+ load_plugin_by_name(tabs, start_tab_index, fm_mine_type, std::move(file_selection_handler), std::move(instance));
while(!tabs.empty() || matrix) {
if(matrix) {
@@ -500,7 +513,7 @@ namespace QuickMedia {
fm_mine_type = FILE_MANAGER_MIME_TYPE_IMAGE;
file_selection_handler = std::move(saucenao_file_selection_handler);
}
- load_plugin_by_name(tabs, start_tab_index, fm_mine_type, std::move(file_selection_handler));
+ load_plugin_by_name(tabs, start_tab_index, fm_mine_type, std::move(file_selection_handler), "");
}
}
@@ -986,7 +999,7 @@ namespace QuickMedia {
}
}
- void Program::load_plugin_by_name(std::vector<Tab> &tabs, int &start_tab_index, FileManagerMimeType fm_mime_type, FileSelectionHandler file_selection_handler) {
+ void Program::load_plugin_by_name(std::vector<Tab> &tabs, int &start_tab_index, FileManagerMimeType fm_mime_type, FileSelectionHandler file_selection_handler, std::string instance) {
if(!plugin_name || plugin_name[0] == '\0')
return;
@@ -1027,6 +1040,7 @@ namespace QuickMedia {
create_launcher_body_item("Readm", "readm", resources_root + "icons/readm_launcher.png"),
create_launcher_body_item("Matrix", "matrix", resources_root + "icons/matrix_launcher.png"),
create_launcher_body_item("Nyaa.si", "nyaa.si", resources_root + "icons/nyaa_si_launcher.png"),
+ create_launcher_body_item("PeerTube", "peertube", resources_root + "images/peertube_logo.png"),
create_launcher_body_item("SauceNAO", "saucenao", ""),
create_launcher_body_item("Soundcloud", "soundcloud", resources_root + "icons/soundcloud_launcher.png"),
create_launcher_body_item("YouTube", "youtube", resources_root + "icons/yt_launcher.png"),
@@ -1195,6 +1209,12 @@ namespace QuickMedia {
auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, youtube_url);
video_content_page(nullptr, youtube_video_page.get(), "", false, nullptr, 0);
}
+ } else if(strcmp(plugin_name, "peertube") == 0) {
+ if(instance.empty()) {
+ tabs.push_back(Tab{create_body(false, false), std::make_unique<PeertubeInstanceSelectionPage>(this), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
+ } else {
+ tabs.push_back(Tab{create_body(false, true), std::make_unique<PeertubeSearchPage>(this, instance), create_search_bar("Search...", 350)});
+ }
} else if(strcmp(plugin_name, "pornhub") == 0) {
check_youtube_dl_installed(plugin_name);
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.pornhub.com/", sf::Vector2i(320/1.5f, 180/1.5f), false);
@@ -1739,6 +1759,8 @@ namespace QuickMedia {
bool redraw = true;
for(Tab &tab : tabs) {
+ assert(tab.body.get());
+ assert(tab.page.get());
if(tab.body->attach_side == AttachSide::BOTTOM)
tab.body->select_last_item();
tab.page->on_navigate_to_page(tab.body.get());
@@ -2429,11 +2451,14 @@ namespace QuickMedia {
unsigned long num_items = 0;
unsigned long bytes_after = 0;
unsigned char *properties = nullptr;
- if(XGetWindowProperty(display, window, wm_state_atom, 0, 1024, False, XA_ATOM, &type, &format, &num_items, &bytes_after, &properties) < Success || !properties) {
+ if(XGetWindowProperty(display, window, wm_state_atom, 0, 1024, False, XA_ATOM, &type, &format, &num_items, &bytes_after, &properties) < Success) {
fprintf(stderr, "Failed to get window wm state property\n");
return false;
}
+ if(!properties)
+ return false;
+
bool is_fullscreen = false;
Atom *atoms = (Atom*)properties;
for(unsigned long i = 0; i < num_items; ++i) {