aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index cb570fc..ff78735 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -9,6 +9,7 @@
#include "../plugins/Matrix.hpp"
#include "../plugins/Pleroma.hpp"
#include "../plugins/Spotify.hpp"
+#include "../plugins/Soundcloud.hpp"
#include "../plugins/FileManager.hpp"
#include "../plugins/Pipe.hpp"
#include "../include/Scale.hpp"
@@ -453,7 +454,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, spotify, nyaa.si, matrix, file-manager or pipe\n");
+ fprintf(stderr, " plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, pornhub, youtube, spotify, soundcloud, 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");
@@ -497,6 +498,10 @@ namespace QuickMedia {
plugin_name = argv[i];
plugin_logo_path = resources_root + "images/spotify_logo.png";
no_video = true;
+ } else if(strcmp(argv[i], "soundcloud") == 0) {
+ plugin_name = argv[i];
+ plugin_logo_path = resources_root + "images/soundcloud_logo.png";
+ no_video = true;
} else if(strcmp(argv[i], "pornhub") == 0) {
plugin_name = argv[i];
plugin_logo_path = resources_root + "images/pornhub_logo.png";
@@ -689,6 +694,9 @@ namespace QuickMedia {
} else if(strcmp(plugin_name, "spotify") == 0) {
auto search_body = create_body();
tabs.push_back(Tab{std::move(search_body), std::make_unique<SpotifyPodcastSearchPage>(this), create_search_bar("Search...", 250)});
+ } else if(strcmp(plugin_name, "soundcloud") == 0) {
+ auto search_body = create_body();
+ tabs.push_back(Tab{std::move(search_body), std::make_unique<SoundcloudSearchPage>(this), create_search_bar("Search...", 500)});
} else if(strcmp(plugin_name, "mastodon") == 0 || strcmp(plugin_name, "pleroma") == 0) {
auto pleroma = std::make_shared<Pleroma>();
auto search_body = create_body();
@@ -1106,11 +1114,12 @@ namespace QuickMedia {
std::function<void()> submit_handler;
submit_handler = [this, &submit_handler, &after_submit_handler, &json_chapters, &tabs, &tab_associated_data, &selected_tab, &loop_running, &redraw]() {
- BodyItem *selected_item = tabs[selected_tab].body->get_selected();
+ auto selected_item = tabs[selected_tab].body->get_selected_shared();
if(!selected_item)
return;
std::vector<Tab> new_tabs;
+ tabs[selected_tab].page->submit_body_item = selected_item;
PluginResult submit_result = tabs[selected_tab].page->submit(selected_item->get_title(), selected_item->url, new_tabs);
if(submit_result != PluginResult::OK) {
// TODO: Show the exact cause of error (get error message from curl).
@@ -1135,11 +1144,14 @@ namespace QuickMedia {
tabs[selected_tab].body = std::move(new_tabs[0].body);
else
loop_running = false;
+ tabs[selected_tab].page->submit_body_item = nullptr;
return;
}
- if(new_tabs.empty())
+ if(new_tabs.empty()) {
+ tabs[selected_tab].page->submit_body_item = nullptr;
return;
+ }
if(after_submit_handler)
after_submit_handler(new_tabs);
@@ -1151,7 +1163,7 @@ namespace QuickMedia {
hide_virtual_keyboard();
if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::MANGA_IMAGES) {
- select_episode(selected_item, false);
+ select_episode(selected_item.get(), false);
Body *chapters_body = tabs[selected_tab].body.get();
chapters_body->filter_search_fuzzy(""); // Needed (or not really) to go to the next chapter when reaching the last page of a chapter
MangaImagesPage *manga_images_page = static_cast<MangaImagesPage*>(new_tabs[0].page.get());
@@ -1188,9 +1200,9 @@ namespace QuickMedia {
image_board_thread_page(static_cast<ImageBoardThreadPage*>(new_tabs[0].page.get()), new_tabs[0].body.get());
} else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::VIDEO) {
current_page = PageType::VIDEO_CONTENT;
- video_content_page(static_cast<VideoPage*>(new_tabs[0].page.get()), selected_item->url, selected_item->get_title(), false);
+ video_content_page(static_cast<VideoPage*>(new_tabs[0].page.get()), selected_item->get_title(), false);
} else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::CHAT) {
- body_set_selected_item(tabs[selected_tab].body.get(), selected_item);
+ body_set_selected_item(tabs[selected_tab].body.get(), selected_item.get());
current_page = PageType::CHAT;
current_chat_room = matrix->get_room_by_id(selected_item->url);
@@ -1225,6 +1237,7 @@ namespace QuickMedia {
json_chapters = &chapters_json;
}
+ tabs[selected_tab].page->submit_body_item = nullptr;
redraw = true;
hide_virtual_keyboard();
};
@@ -1727,7 +1740,7 @@ namespace QuickMedia {
#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
- void Program::video_content_page(VideoPage *video_page, std::string video_url, std::string video_title, bool download_if_streaming_fails) {
+ void Program::video_content_page(VideoPage *video_page, std::string video_title, bool download_if_streaming_fails) {
sf::Clock time_watched_timer;
bool added_recommendations = false;
bool video_loaded = false;
@@ -1735,6 +1748,7 @@ namespace QuickMedia {
const bool is_matrix = strcmp(plugin_name, "matrix") == 0;
PageType previous_page = pop_page_stack();
+ std::string video_url = video_page->get_url();
bool video_url_is_local = false;
if(download_if_streaming_fails) {
@@ -2824,7 +2838,8 @@ namespace QuickMedia {
current_page = PageType::VIDEO_CONTENT;
watched_videos.clear();
// TODO: Use real title
- video_content_page(thread_page, selected_item->attached_content_url, "No title.webm", true);
+ thread_page->video_url = selected_item->attached_content_url;
+ video_content_page(thread_page, "No title.webm", true);
redraw = true;
} else {
if(downloading_image && load_image_future.valid())
@@ -4117,7 +4132,8 @@ namespace QuickMedia {
watched_videos.clear();
current_page = PageType::VIDEO_CONTENT;
// TODO: Add title
- video_content_page(video_page.get(), url, "No title", false);
+ video_page->url = url;
+ video_content_page(video_page.get(), "No title", false);
redraw = true;
} else {
const char *launch_program = "xdg-open";
@@ -4186,8 +4202,7 @@ namespace QuickMedia {
if(selected_item_message) {
MessageType message_type = selected_item_message->type;
- std::string *selected_url = &selected->url;
- if(!selected_url->empty()) {
+ if(!selected->url.empty()) {
if(message_type == MessageType::VIDEO || message_type == MessageType::IMAGE || message_type == MessageType::AUDIO) {
page_stack.push(PageType::CHAT);
watched_videos.clear();
@@ -4196,13 +4211,14 @@ namespace QuickMedia {
bool prev_no_video = no_video;
no_video = is_audio;
// TODO: Add title
- video_content_page(video_page.get(), *selected_url, "No title", message_type == MessageType::VIDEO || message_type == MessageType::AUDIO);
+ video_page->url = selected->url;
+ video_content_page(video_page.get(), "No title", message_type == MessageType::VIDEO || message_type == MessageType::AUDIO);
no_video = prev_no_video;
redraw = true;
return true;
}
- launch_url(*selected_url);
+ launch_url(selected->url);
return true;
}
}