aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Peertube.hpp4
-rw-r--r--src/DownloadUtils.cpp4
-rw-r--r--src/QuickMedia.cpp16
-rw-r--r--src/plugins/Peertube.cpp1
4 files changed, 22 insertions, 3 deletions
diff --git a/plugins/Peertube.hpp b/plugins/Peertube.hpp
index 88ba1ca..c8578f7 100644
--- a/plugins/Peertube.hpp
+++ b/plugins/Peertube.hpp
@@ -8,6 +8,7 @@ namespace QuickMedia {
PeertubeInstanceSelectionPage(Program *program) : LazyFetchPage(program) {}
const char* get_title() const override { return "Select instance"; }
bool allow_submit_no_selection() const override { return true; }
+ bool submit_is_async() const override { return false; }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
};
@@ -23,6 +24,7 @@ namespace QuickMedia {
PeertubeSearchPage(Program *program, const std::string &server);
const char* get_title() const override { return "Search"; }
bool search_is_filter() override { return false; }
+ bool submit_is_async() const override { return false; }
// Fetches local videos if |str| is empty
SearchResult search(const std::string &str, BodyItems &result_items) override;
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
@@ -41,6 +43,7 @@ namespace QuickMedia {
PeertubeChannelPage(Program *program, const std::string &server, std::string display_name, std::string name) :
LazyFetchPage(program), server(server), name(std::move(name)), title(std::move(display_name)) {}
const char* get_title() const override { return title.c_str(); }
+ bool submit_is_async() const override { return false; }
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
@@ -55,6 +58,7 @@ namespace QuickMedia {
PeertubePlaylistPage(Program *program, const std::string &server, std::string display_name, std::string uuid) :
LazyFetchPage(program), server(server), uuid(std::move(uuid)), title(std::move(display_name)) {}
const char* get_title() const override { return title.c_str(); }
+ bool submit_is_async() const override { return false; }
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
PluginResult lazy_fetch(BodyItems &result_items) override;
diff --git a/src/DownloadUtils.cpp b/src/DownloadUtils.cpp
index 93df291..6df9c74 100644
--- a/src/DownloadUtils.cpp
+++ b/src/DownloadUtils.cpp
@@ -293,8 +293,8 @@ namespace QuickMedia {
bool download_async_gui(const std::string &url, const std::string &file_manager_start_dir, bool no_video) {
char quickmedia_path[PATH_MAX];
- ssize_t bytes_written = readlink("/proc/self/exe", quickmedia_path, sizeof(quickmedia_path));
- if(bytes_written == -1 || bytes_written == sizeof(quickmedia_path))
+ ssize_t bytes_written = readlink("/proc/self/exe", quickmedia_path, sizeof(quickmedia_path) - 1);
+ if(bytes_written == -1)
strcpy(quickmedia_path, "quickmedia");
else
quickmedia_path[bytes_written] = '\0';
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 32696b6..aef1073 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -46,6 +46,7 @@
#include <malloc.h>
#include <unistd.h>
#include <libgen.h>
+#include <limits.h>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Window/Clipboard.hpp>
@@ -314,6 +315,15 @@ namespace QuickMedia {
return body_item;
}
+ static bool convert_to_absolute_path(std::filesystem::path &path) {
+ char resolved[PATH_MAX];
+ if(!realpath(path.c_str(), resolved))
+ return false;
+
+ path = resolved;
+ return true;
+ }
+
int Program::run(int argc, char **argv) {
if(argc < 1) {
usage();
@@ -456,8 +466,12 @@ namespace QuickMedia {
}
std::filesystem::path home_path = get_home_dir().data;
- if(file_manager_start_dir.empty())
+ if(file_manager_start_dir.empty()) {
file_manager_start_dir = home_path;
+ } else {
+ if(!convert_to_absolute_path(file_manager_start_dir))
+ fprintf(stderr, "Warning: failed to get absolute path for path: %s\n", file_manager_start_dir.c_str());
+ }
int start_tab_index = 0;
FileManagerMimeType fm_mine_type = FILE_MANAGER_MIME_TYPE_ALL;
diff --git a/src/plugins/Peertube.cpp b/src/plugins/Peertube.cpp
index df715c1..db55584 100644
--- a/src/plugins/Peertube.cpp
+++ b/src/plugins/Peertube.cpp
@@ -50,6 +50,7 @@ namespace QuickMedia {
if(hours >= 1) {
minutes -= (hours * 60);
seconds -= (hours * 60 * 60);
+ seconds -= (minutes * 60);
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d", hours, minutes, seconds);
} else if(minutes >= 1) {
seconds -= (minutes * 60);