aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-12 01:08:31 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-12 01:08:31 +0200
commitc944b7b874ce2296b0c67cd9e7c670304c514e1f (patch)
tree1a13a4381f2bd3126cbd8a1b4161ad2d962b9d23 /src
parentef4442c6f58929f2eefb10be218b8d3638d88358 (diff)
Sneed moment
Diffstat (limited to 'src')
-rw-r--r--src/FileAnalyzer.cpp6
-rw-r--r--src/QuickMedia.cpp10
-rw-r--r--src/plugins/FileManager.cpp2
-rw-r--r--src/plugins/Matrix.cpp12
4 files changed, 14 insertions, 16 deletions
diff --git a/src/FileAnalyzer.cpp b/src/FileAnalyzer.cpp
index f16c232..aeb88f7 100644
--- a/src/FileAnalyzer.cpp
+++ b/src/FileAnalyzer.cpp
@@ -82,9 +82,9 @@ namespace QuickMedia {
case ContentType::AUDIO_MPEG: return "audio/mpeg";
case ContentType::AUDIO_MIDI: return "audio/midi";
case ContentType::AUDIO_WAVE: return "audio/wave";
- case ContentType::AUDIO_FLAC: return "audio/wave";
+ case ContentType::AUDIO_FLAC: return "audio/flac";
case ContentType::AUDIO_VORBIS: return "audio/ogg";
- case ContentType::AUDIO_OPUS: return "audio/ogg";
+ case ContentType::AUDIO_OPUS: return "audio/opus";
case ContentType::IMAGE_JPEG: return "image/jpeg";
case ContentType::IMAGE_PNG: return "image/png";
case ContentType::IMAGE_GIF: return "image/gif";
@@ -129,7 +129,7 @@ namespace QuickMedia {
bool video_get_first_frame(const FileAnalyzer &file, const char *destination_path, int width, int height) {
Path destination_path_tmp = destination_path;
- destination_path_tmp.append(".tmp.jpg");
+ destination_path_tmp.append(".tmp.jpg"); // TODO: .png, but the below code also needs to be changed for that
const int middle_seconds = file.get_duration_seconds().value_or(0.0) / 2.0;
char middle_seconds_str[32];
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index fa8dd66..3e77797 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -378,9 +378,6 @@ namespace QuickMedia {
return -1;
}
- if(argc == 1)
- plugin_name = "launcher";
-
Window parent_window = None;
video_max_height = 0;
std::vector<Tab> tabs;
@@ -489,11 +486,8 @@ namespace QuickMedia {
}
}
- if(!plugin_name) {
- fprintf(stderr, "Missing plugin argument\n");
- usage();
- return -1;
- }
+ if(!plugin_name)
+ plugin_name = "launcher";
if(low_cpu_mode)
FPS_IDLE = 3;
diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp
index 5fd6670..45c61bf 100644
--- a/src/plugins/FileManager.cpp
+++ b/src/plugins/FileManager.cpp
@@ -21,6 +21,8 @@ namespace QuickMedia {
const char *path_c = path.c_str();
int len = strlen(path_c);
for(int i = len - 1; i >= 0; --i) {
+ if(path_c[i] == '/')
+ return "";
if(path_c[i] == '.')
return path_c + i;
}
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 00009fd..14f49bf 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3674,7 +3674,7 @@ namespace QuickMedia {
PluginResult Matrix::post_file(RoomData *room, const std::string &filepath, std::string filename, std::string &event_id_response, std::string &err_msg) {
UploadInfo file_info;
UploadInfo thumbnail_info;
- PluginResult upload_file_result = upload_file(room, filepath, file_info, thumbnail_info, err_msg);
+ PluginResult upload_file_result = upload_file(room, filepath, filename, file_info, thumbnail_info, err_msg);
if(upload_file_result != PluginResult::OK)
return upload_file_result;
@@ -3689,7 +3689,7 @@ namespace QuickMedia {
return post_message(room, filename, event_id_response, file_info_opt, thumbnail_info_opt);
}
- PluginResult Matrix::upload_file(RoomData *room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg, bool upload_thumbnail) {
+ PluginResult Matrix::upload_file(RoomData *room, const std::string &filepath, std::string filename, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg, bool upload_thumbnail) {
FileAnalyzer file_analyzer;
if(!file_analyzer.load_file(filepath.c_str(), true)) {
err_msg = "Failed to load " + filepath;
@@ -3725,7 +3725,7 @@ namespace QuickMedia {
if(tmp_file != -1) {
if(video_get_first_frame(file_analyzer, tmp_filename, thumbnail_max_size.x, thumbnail_max_size.y)) {
UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails.
- PluginResult upload_thumbnail_result = upload_file(room, tmp_filename, thumbnail_info, upload_info_ignored, err_msg, false);
+ PluginResult upload_thumbnail_result = upload_file(room, tmp_filename, "", thumbnail_info, upload_info_ignored, err_msg, false);
if(upload_thumbnail_result != PluginResult::OK) {
close(tmp_file);
remove(tmp_filename);
@@ -3750,7 +3750,7 @@ namespace QuickMedia {
thumbnail_path = filepath;
UploadInfo upload_info_ignored; // Ignore because it wont be set anyways. Thumbnails dont have thumbnails.
- PluginResult upload_thumbnail_result = upload_file(room, thumbnail_path, thumbnail_info, upload_info_ignored, err_msg, false);
+ PluginResult upload_thumbnail_result = upload_file(room, thumbnail_path, "", thumbnail_info, upload_info_ignored, err_msg, false);
if(upload_thumbnail_result != PluginResult::OK) {
close(tmp_file);
remove(tmp_filename);
@@ -3771,7 +3771,9 @@ namespace QuickMedia {
{ "--data-binary", "@" + filepath }
};
- const char *filename = file_get_filename(filepath);
+ if(filename.empty())
+ filename = file_get_filename(filepath);
+
std::string filename_escaped = url_param_encode(filename);
char url[512];