aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-12-21 20:47:59 +0100
committerdec05eba <dec05eba@protonmail.com>2020-12-21 20:47:59 +0100
commit5394d8e2c85b52d7375a02f72e089d22a82fba1b (patch)
tree3d14614b85b28a78edfe269a696daf02bc51de15
parent4f8e4d11e51e2436b957157de86755f5f8879f61 (diff)
Add pipe plugin, increase video load timeout to 500 seconds
-rw-r--r--README.md2
-rw-r--r--TODO6
-rw-r--r--include/Body.hpp1
-rw-r--r--plugins/Pipe.hpp15
-rw-r--r--src/QuickMedia.cpp11
-rw-r--r--src/VideoPlayer.cpp2
-rw-r--r--src/plugins/Pipe.cpp33
7 files changed, 64 insertions, 6 deletions
diff --git a/README.md b/README.md
index 59293dc..4c495d1 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Cache is stored under `$HOME/.cache/quickmedia`.
```
usage: QuickMedia <plugin> [--tor] [--use-system-mpv-config] [--dir <directory>]
OPTIONS:
- plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, youtube, nyaa.si, matrix, file-manager
+ plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, youtube, nyaa.si, matrix, file-manager or pipe
--no-video Only play audio when playing a video. Disabled by default
--tor Use tor. Disabled by default
--use-system-mpv-config Use system mpv config instead of no config. Disabled by default
diff --git a/TODO b/TODO
index 6208d37..34aba01 100644
--- a/TODO
+++ b/TODO
@@ -152,4 +152,8 @@ Instead of doing a GET for the first N bytes to check if a video is streamable,
Create thumbnail when uploading an image in matrix.
If a message reply is edited and its a reply to us, then we want the text to be red even if its edited.
Implement matrix spoiler, see: https://github.com/matrix-org/matrix-doc/blob/master/proposals/2010-spoilers.md.
-Make the messages that mention us red using the matrix notification api that we already use. Mark those messages as mentions us. \ No newline at end of file
+Make the messages that mention us red using the matrix notification api that we already use. Mark those messages as mentions us.
+Replace sfml font glyph loading completely with FreeType. There is a very old bug in sfml that causes text to get corrupt sometimes. Im guessing this happens when adding new characters to the font atlas and that coordinates for the glyphs become incorrect?
+Add arguments to pipe plugin to pass input and output fifo for sending commands to QuickMedia and receiving events.
+Update thumbnails in file-manager if an image is replaced, by including the modify date of the image in the thumbnail cache as well.
+Create a workaround for dwm terminal swallow patch stealing mpv when moving QuickMedia to another monitor sometimes. Maybe check for structure notify events on mpv and reparent and select input on the mpv window again? \ No newline at end of file
diff --git a/include/Body.hpp b/include/Body.hpp
index 62d8b27..676eef8 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -132,6 +132,7 @@ namespace QuickMedia {
bool dirty_description;
bool dirty_author;
bool dirty_timestamp;
+ // TODO: Remove this and instead if |thumbnail_url| starts with file://, then its a local file
bool thumbnail_is_local;
std::unique_ptr<Text> title_text;
std::unique_ptr<Text> description_text;
diff --git a/plugins/Pipe.hpp b/plugins/Pipe.hpp
new file mode 100644
index 0000000..0711ee4
--- /dev/null
+++ b/plugins/Pipe.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "Page.hpp"
+
+namespace QuickMedia {
+ class PipePage : public Page {
+ public:
+ PipePage(Program *program) : Page(program) {}
+ const char* get_title() const override { return ""; }
+ PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ bool is_single_page() const override { return true; }
+
+ static void load_body_items_from_stdin(BodyItems &items);
+ };
+} \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index db0f9f6..1191ecb 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -9,6 +9,7 @@
#include "../plugins/Matrix.hpp"
#include "../plugins/Pleroma.hpp"
#include "../plugins/FileManager.hpp"
+#include "../plugins/Pipe.hpp"
#include "../include/Scale.hpp"
#include "../include/Program.hpp"
#include "../include/VideoPlayer.hpp"
@@ -396,7 +397,7 @@ namespace QuickMedia {
static void usage() {
fprintf(stderr, "usage: QuickMedia <plugin> [--tor] [--no-video] [--use-system-mpv-config] [--dir <directory>]\n");
fprintf(stderr, "OPTIONS:\n");
- fprintf(stderr, " plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, pornhub, youtube, nyaa.si, matrix or file-manager\n");
+ fprintf(stderr, " plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, pornhub, youtube, nyaa.si, matrix, file-manager or pipe\n");
fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n");
fprintf(stderr, " --tor Use tor. Disabled by default\n");
fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n");
@@ -455,6 +456,8 @@ namespace QuickMedia {
plugin_logo_path = resources_root + "images/pleroma_logo.png";
} else if(strcmp(argv[i], "file-manager") == 0) {
plugin_name = argv[i];
+ } else if(strcmp(argv[i], "pipe") == 0) {
+ plugin_name = argv[i];
}
}
@@ -597,6 +600,10 @@ namespace QuickMedia {
auto file_manager_body = create_body();
file_manager_page->get_files_in_directory(file_manager_body->items);
tabs.push_back(Tab{std::move(file_manager_body), std::move(file_manager_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
+ } else if(strcmp(plugin_name, "pipe") == 0) {
+ auto pipe_body = create_body();
+ PipePage::load_body_items_from_stdin(pipe_body->items);
+ tabs.push_back(Tab{std::move(pipe_body), std::make_unique<PipePage>(this), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
} else if(strcmp(plugin_name, "youtube") == 0) {
auto search_body = create_body();
tabs.push_back(Tab{std::move(search_body), std::make_unique<YoutubeSearchPage>(this), create_search_bar("Search...", 350)});
@@ -1817,8 +1824,6 @@ namespace QuickMedia {
window_size.y = event.size.height;
sf::FloatRect visible_area(0, 0, window_size.x, window_size.y);
window.setView(sf::View(visible_area));
- } else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
- current_page = previous_page;
}
}
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index c6f5a36..22d1762 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -14,7 +14,7 @@
#include <signal.h>
const int RETRY_TIME_MS = 500;
-const int MAX_RETRIES_CONNECT = 20;
+const int MAX_RETRIES_CONNECT = 1000;
const int READ_TIMEOUT_MS = 200;
namespace QuickMedia {
diff --git a/src/plugins/Pipe.cpp b/src/plugins/Pipe.cpp
new file mode 100644
index 0000000..5d7d269
--- /dev/null
+++ b/src/plugins/Pipe.cpp
@@ -0,0 +1,33 @@
+#include "../../plugins/Pipe.hpp"
+#include <string>
+#include <iostream>
+
+namespace QuickMedia {
+ PluginResult PipePage::submit(const std::string &title, const std::string&, std::vector<Tab> &result_tabs) {
+ puts(title.c_str());
+ return PluginResult::OK;
+ }
+
+ // static
+ void PipePage::load_body_items_from_stdin(BodyItems &items) {
+ std::string line;
+ while(std::getline(std::cin, line)) {
+ std::string name;
+ std::string filepath;
+ size_t split_index = line.find('|');
+ if(split_index == std::string::npos) {
+ name = std::move(line);
+ } else {
+ name = line.substr(0, split_index);
+ filepath = line.substr(split_index + 1);
+ }
+
+ auto body_item = BodyItem::create(std::move(name));
+ if(!filepath.empty()) {
+ body_item->thumbnail_url = std::move(filepath);
+ body_item->thumbnail_is_local = true;
+ }
+ items.push_back(std::move(body_item));
+ }
+ }
+} \ No newline at end of file