aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FileAnalyzer.cpp4
-rw-r--r--src/ImageViewer.cpp2
-rw-r--r--src/QuickMedia.cpp56
-rw-r--r--src/plugins/Mangadex.cpp2
-rw-r--r--src/plugins/NyaaSi.cpp2
5 files changed, 36 insertions, 30 deletions
diff --git a/src/FileAnalyzer.cpp b/src/FileAnalyzer.cpp
index 1f46150..82d2c06 100644
--- a/src/FileAnalyzer.cpp
+++ b/src/FileAnalyzer.cpp
@@ -20,10 +20,12 @@ namespace QuickMedia {
// What about audio ogg files that are not opus?
// TODO: Test all of these
- static const std::array<MagicNumber, 20> magic_numbers = {
+ static const std::array<MagicNumber, 22> magic_numbers = {
MagicNumber{ {'R', 'I', 'F', 'F', -1, -1, -1, -1, 'A', 'V', 'I', ' '}, 12, ContentType::VIDEO_AVI },
MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'p', 'i', 's', 'o', 'm'}, 12, ContentType::VIDEO_MP4 },
MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'p', 'm', 'p', '4', '2'}, 12, ContentType::VIDEO_MP4 },
+ MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', 'm', 'p', '4', '2'}, 11, ContentType::VIDEO_MP4 },
+ MagicNumber{ {0x00, 0x00, 0x00, -1, 'f', 't', 'y', '3', 'g', 'p', '5'}, 11, ContentType::VIDEO_MP4 },
MagicNumber{ {0x1A, 0x45, 0xDF, 0xA3}, 4, ContentType::VIDEO_WEBM },
MagicNumber{ {'.', 's', 'n', 'd'}, 4, ContentType::AUDIO_BASIC },
MagicNumber{ {'F', 'O', 'R', 'M', -1, -1, -1, -1, 'A', 'I', 'F', 'F'}, 12, ContentType::AUDIO_AIFF },
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index b544165..a8e6041 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -19,7 +19,7 @@ namespace QuickMedia {
page_text("", *font, 14)
{
if(manga_images_page->get_number_of_images(num_pages) != ImageResult::OK) {
- show_notification("Plugin", "Failed to get number of images", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to get number of images", Urgency::CRITICAL);
return;
}
current_page = std::min(current_page, num_pages);
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e374dfb..614fad3 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -766,7 +766,7 @@ namespace QuickMedia {
if(create_directory_recursive(video_history_dir) != 0) {
std::string err_msg = "Failed to create video history directory ";
err_msg += video_history_dir.data;
- show_notification("Video player", err_msg.c_str(), Urgency::CRITICAL);
+ show_notification("QuickMedia", err_msg.c_str(), Urgency::CRITICAL);
exit(1);
}
@@ -798,12 +798,12 @@ namespace QuickMedia {
// TOOD: Make generic, instead of checking for plugin
Path content_storage_dir = get_storage_dir().join(plugin_name);
if(create_directory_recursive(content_storage_dir) != 0) {
- show_notification("Storage", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to create directory: " + content_storage_dir.data, Urgency::CRITICAL);
exit(1);
}
Path credentials_storage_dir = get_storage_dir().join("credentials");
if(create_directory_recursive(credentials_storage_dir) != 0) {
- show_notification("Storage", "Failed to create directory: " + credentials_storage_dir.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to create directory: " + credentials_storage_dir.data, Urgency::CRITICAL);
exit(1);
}
// TODO: Make asynchronous
@@ -1175,9 +1175,9 @@ namespace QuickMedia {
TrackResult track_result = trackable_page->track(selected_item->get_title());
// TODO: Show proper error message when this fails. For example if we are already tracking the manga
if(track_result == TrackResult::OK) {
- show_notification("Media tracker", "You are now tracking \"" + trackable_page->content_title + "\" after \"" + selected_item->get_title() + "\"", Urgency::LOW);
+ show_notification("QuickMedia", "You are now tracking \"" + trackable_page->content_title + "\" after \"" + selected_item->get_title() + "\"", Urgency::LOW);
} else {
- show_notification("Media tracker", "Failed to track media \"" + trackable_page->content_title + "\", chapter: \"" + selected_item->get_title() + "\"", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to track media \"" + trackable_page->content_title + "\", chapter: \"" + selected_item->get_title() + "\"", Urgency::CRITICAL);
}
}
}
@@ -1418,7 +1418,7 @@ namespace QuickMedia {
std::string err_msg = "Failed to extract id of youtube url ";
err_msg += video_url;
err_msg + ", video wont be saved in recommendations";
- show_notification("Video player", err_msg.c_str(), Urgency::LOW);
+ show_notification("QuickMedia", err_msg.c_str(), Urgency::LOW);
return;
}
@@ -1849,7 +1849,7 @@ namespace QuickMedia {
return LoadImageResult::FAILED;
}
} else {
- show_notification("Manga", "Failed to load image for page " + std::to_string(image_index + 1) + ". Image filepath: " + image_path.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to load image for page " + std::to_string(image_index + 1) + ". Image filepath: " + image_path.data, Urgency::CRITICAL);
error_message = std::string("Failed to load image for page ") + std::to_string(image_index + 1);
return LoadImageResult::FAILED;
}
@@ -1922,15 +1922,15 @@ namespace QuickMedia {
if(try_backup_url) {
image_content.clear();
if(download_to_string(new_url, image_content, extra_args, is_tor_enabled(), true) != DownloadResult::OK || image_content.size() <= 255) {
- show_notification("Manganelo", "Failed to download image: " + new_url, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL);
return false;
}
} else {
- show_notification("Manganelo", "Failed to download image: " + url, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return false;
}
} else {
- show_notification("Manga", "Failed to download image: " + url, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return false;
}
}
@@ -1938,7 +1938,7 @@ namespace QuickMedia {
Path image_filepath_tmp(image_filepath.data + ".tmp");
if(file_overwrite(image_filepath_tmp, image_content) != 0) {
- show_notification("Storage", "Failed to save image to file: " + image_filepath_tmp.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to save image to file: " + image_filepath_tmp.data, Urgency::CRITICAL);
return false;
}
@@ -1978,7 +1978,7 @@ namespace QuickMedia {
if(rename_immediately) {
if(rename(image_filepath_tmp.data.c_str(), image_filepath.data.c_str()) != 0) {
perror(image_filepath_tmp.data.c_str());
- show_notification("Storage", "Failed to save image to file: " + image_filepath.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to save image to file: " + image_filepath.data, Urgency::CRITICAL);
return false;
}
}
@@ -2001,14 +2001,14 @@ namespace QuickMedia {
content_cache_dir = get_cache_dir().join(images_page->get_service_name()).join(manga_id_base64).join(base64_encode(images_page->get_chapter_name()));
if(create_directory_recursive(content_cache_dir) != 0) {
- show_notification("Storage", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL);
current_page = pop_page_stack();
return 0;
}
int num_images = 0;
if(images_page->get_number_of_images(num_images) != ImageResult::OK) {
- show_notification("Plugin", "Failed to get number of images", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to get number of images", Urgency::CRITICAL);
current_page = pop_page_stack();
return 0;
}
@@ -2052,7 +2052,7 @@ namespace QuickMedia {
json_chapter["total"] = num_images;
json_chapters[images_page->get_chapter_name()] = json_chapter;
if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) {
- show_notification("Manga progress", "Failed to save manga progress", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to save manga progress", Urgency::CRITICAL);
}
bool error = !error_message.getString().isEmpty();
@@ -2206,14 +2206,14 @@ namespace QuickMedia {
content_cache_dir = get_cache_dir().join(images_page->get_service_name()).join(manga_id_base64).join(base64_encode(images_page->get_chapter_name()));
if(create_directory_recursive(content_cache_dir) != 0) {
- show_notification("Storage", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to create directory: " + content_cache_dir.data, Urgency::CRITICAL);
current_page = pop_page_stack();
return;
}
int num_images = 0;
if(images_page->get_number_of_images(num_images) != ImageResult::OK) {
- show_notification("Plugin", "Failed to get number of images", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to get number of images", Urgency::CRITICAL);
current_page = pop_page_stack();
return;
}
@@ -2246,7 +2246,7 @@ namespace QuickMedia {
json_chapter["total"] = image_viewer.get_num_pages();
json_chapters[images_page->get_chapter_name()] = json_chapter;
if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) {
- show_notification("Manga progress", "Failed to save manga progress", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to save manga progress", Urgency::CRITICAL);
}
while(current_page == PageType::IMAGES_CONTINUOUS) {
@@ -2272,7 +2272,7 @@ namespace QuickMedia {
json_chapter["current"] = latest_read;
json_chapters[images_page->get_chapter_name()] = json_chapter;
if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) {
- show_notification("Manga progress", "Failed to save manga progress", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to save manga progress", Urgency::CRITICAL);
}
}
}
@@ -2353,11 +2353,11 @@ namespace QuickMedia {
captcha_sprite.setTexture(captcha_texture, true);
challenge_description_text.setString(challenge_info.description);
} else {
- show_notification("Google captcha", "Failed to load downloaded captcha image", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to load downloaded captcha image", Urgency::CRITICAL);
navigation_stage = NavigationStage::VIEWING_COMMENTS;
}
} else {
- show_notification("Google captcha", "Failed to download captcha image", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to download captcha image", Urgency::CRITICAL);
navigation_stage = NavigationStage::VIEWING_COMMENTS;
}
};
@@ -2378,7 +2378,7 @@ namespace QuickMedia {
challenge_info = new_challenge_info.value();
request_google_captcha_image(challenge_info);
} else {
- show_notification("Google captcha", "Failed to get captcha challenge", Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to get captcha challenge", Urgency::CRITICAL);
navigation_stage = NavigationStage::VIEWING_COMMENTS;
}
}, is_tor_enabled());
@@ -2603,7 +2603,7 @@ namespace QuickMedia {
captcha_solved_time.restart();
post_comment();
} else if(new_challenge_info) {
- show_notification("Google captcha", "Failed to solve captcha, please try again");
+ show_notification("QuickMedia", "Failed to solve captcha, please try again");
challenge_info = new_challenge_info.value();
navigation_stage = NavigationStage::SOLVING_POST_CAPTCHA;
for(size_t i = 0; i < selected_captcha_images.size(); ++i) {
@@ -3247,14 +3247,18 @@ namespace QuickMedia {
video_content_page(video_page.get(), url, "No title");
redraw = true;
} else {
+ const char *launch_program = "xdg-open";
if(!is_program_executable_by_name("xdg-open")) {
- show_notification("Nyaa.si", "xdg-utils which provides xdg-open needs to be installed to download torrents", Urgency::CRITICAL);
- return;
+ launch_program = getenv("BROWSER");
+ if(!launch_program) {
+ show_notification("QuickMedia", "xdg-utils which provides xdg-open needs to be installed to open urls. Alternatively set the $BROWSER environment variable to a browser", Urgency::CRITICAL);
+ return;
+ }
}
std::string url_modified = url;
if(strncmp(url.c_str(), "http://", 7) != 0 && strncmp(url.c_str(), "https://", 8) != 0)
url_modified = "https://" + url;
- const char *args[] = { "xdg-open", url_modified.c_str(), nullptr };
+ const char *args[] = { launch_program, url_modified.c_str(), nullptr };
exec_program_async(args, nullptr);
}
};
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 0ccecdd..3574914 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -42,7 +42,7 @@ namespace QuickMedia {
static bool get_cookie_filepath(std::string &cookie_filepath) {
Path cookie_path = get_storage_dir().join("cookies");
if(create_directory_recursive(cookie_path) != 0) {
- show_notification("Storage", "Failed to create directory: " + cookie_path.data, Urgency::CRITICAL);
+ show_notification("QuickMedia", "Failed to create directory: " + cookie_path.data, Urgency::CRITICAL);
return false;
}
cookie_filepath = cookie_path.join("mangadex.txt").data;
diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp
index 860eb71..3ae6ffb 100644
--- a/src/plugins/NyaaSi.cpp
+++ b/src/plugins/NyaaSi.cpp
@@ -385,7 +385,7 @@ namespace QuickMedia {
(void)result_tabs;
if(strncmp(url.c_str(), "magnet:?", 8) == 0) {
if(!is_program_executable_by_name("xdg-open")) {
- show_notification("Nyaa.si", "xdg-utils which provides xdg-open needs to be installed to download torrents", Urgency::CRITICAL);
+ show_notification("QuickMedia", "xdg-utils which provides xdg-open needs to be installed to download torrents", Urgency::CRITICAL);
return PluginResult::ERR;
}
const char *args[] = { "xdg-open", url.c_str(), nullptr };