aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-07-15 12:48:38 +0200
committerdec05eba <dec05eba@protonmail.com>2022-07-15 12:48:38 +0200
commit6758cdc82e4cb295123b0a84819c6a6ebd5ebad0 (patch)
tree86ed3a0db9134d72937c813ab037688e581766c4
parent0bf55deae8d8a681b32a1fa91908ed1f566dbbf5 (diff)
Youtube: do not autoplay next if starting qm with youtube url, opening youtube url in info page or matrix
-rw-r--r--plugins/Page.hpp4
-rw-r--r--plugins/Youtube.hpp2
-rw-r--r--src/QuickMedia.cpp12
-rw-r--r--src/plugins/Info.cpp2
-rw-r--r--src/plugins/Mangadex.cpp3
-rw-r--r--src/plugins/NyaaSi.cpp2
-rw-r--r--src/plugins/Youtube.cpp2
7 files changed, 19 insertions, 8 deletions
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index c1ca012..6ac0450 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -136,9 +136,10 @@ namespace QuickMedia {
class VideoPage : public Page {
public:
- VideoPage(Program *program, std::string url) : Page(program), url(std::move(url)) {}
+ VideoPage(Program *program, std::string url, bool autoplay = true) : Page(program), url(std::move(url)), autoplay(autoplay) {}
virtual PageTypez get_type() const override { return PageTypez::VIDEO; }
virtual bool autoplay_next_item() { return false; }
+ bool should_autoplay() const { return autoplay; }
virtual BodyItems get_related_media(const std::string &url) { (void)url; return {}; }
virtual PluginResult get_related_pages(const BodyItems &related_videos, const std::string &channel_url, std::vector<Tab> &result_tabs) {
(void)related_videos;
@@ -181,6 +182,7 @@ namespace QuickMedia {
virtual void set_watch_progress(int64_t time_pos_sec, int64_t duration_sec) { (void)time_pos_sec; (void)duration_sec; }
protected:
std::string url;
+ bool autoplay;
};
class BookmarksPage : public LazyFetchPage {
diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp
index 5affe04..cea5d8d 100644
--- a/plugins/Youtube.hpp
+++ b/plugins/Youtube.hpp
@@ -142,7 +142,7 @@ namespace QuickMedia {
class YoutubeVideoPage : public VideoPage {
public:
- YoutubeVideoPage(Program *program, std::string url);
+ YoutubeVideoPage(Program *program, std::string url, bool autoplay = true);
const char* get_title() const override { return ""; }
BodyItems get_related_media(const std::string &url) override;
PluginResult get_related_pages(const BodyItems &related_videos, const std::string &channel_url, std::vector<Tab> &result_tabs) override;
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 147afd9..e710fb5 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1258,7 +1258,7 @@ namespace QuickMedia {
tabs.push_back(Tab{std::move(history_body), std::move(history_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
} else {
current_page = PageType::VIDEO_CONTENT;
- auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, youtube_url);
+ auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, youtube_url, false);
video_content_page(nullptr, youtube_video_page.get(), "", false, nullptr, 0);
}
} else if(strcmp(plugin_name, "peertube") == 0) {
@@ -3113,7 +3113,7 @@ namespace QuickMedia {
BodyItems related_videos;
bool move_in_parent = false;
- if(parent_body && video_page->autoplay_next_item() && play_index + 1 >= 0 && play_index + 1 < (int)parent_body->get_num_items()) {
+ if(parent_body && video_page->autoplay_next_item() && video_page->should_autoplay() && play_index + 1 >= 0 && play_index + 1 < (int)parent_body->get_num_items()) {
parent_body->copy_range(play_index + 1, (size_t)-1, related_videos);
move_in_parent = true;
}
@@ -3568,6 +3568,12 @@ namespace QuickMedia {
} else if(update_err == VideoPlayer::Error::EXITED && video_player->exit_status == 0 && (!is_matrix || is_youtube)) {
std::string new_video_url;
+ if(!video_page->should_autoplay()) {
+ current_page = previous_page;
+ go_to_previous_page = true;
+ break;
+ }
+
if(related_videos_task.valid()) {
TaskResult task_result = run_task_with_loading_screen([&]() {
while(!program_is_dead_in_current_thread()) {
@@ -6270,7 +6276,7 @@ namespace QuickMedia {
watched_videos.clear();
page_stack.push(PageType::CHAT);
current_page = PageType::VIDEO_CONTENT;
- auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, std::move(url));
+ auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, std::move(url), false);
// TODO: Use real title
video_content_page(matrix_chat_page, youtube_video_page.get(), "", false, tabs[MESSAGES_TAB_INDEX].body.get(), tabs[MESSAGES_TAB_INDEX].body->get_selected_item());
redraw = true;
diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp
index 90c8fe1..252cbea 100644
--- a/src/plugins/Info.cpp
+++ b/src/plugins/Info.cpp
@@ -42,7 +42,7 @@ namespace QuickMedia {
const std::string search_url = "https://www.google.com/search?q=" + url_param_encode(search_term);
return open_with_browser(search_url);
} else if(is_youtube_url(args.url)) {
- result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url), nullptr});
+ result_tabs.push_back(Tab{nullptr, std::make_unique<YoutubeVideoPage>(program, args.url, false), nullptr});
return PluginResult::OK;
} else {
return open_with_browser(args.url);
diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp
index 2efd2f1..c100b0b 100644
--- a/src/plugins/Mangadex.cpp
+++ b/src/plugins/Mangadex.cpp
@@ -107,8 +107,11 @@ namespace QuickMedia {
std::string title;
const Json::Value &title_en_json = title_json["en"];
+ const Json::Value &title_ja_json = title_json["ja"];
if(title_en_json.isString())
title = title_en_json.asString();
+ else if(title_ja_json.isString())
+ title = title_ja_json.asString();
else
title = "No title"; // TODO: Verify if this happens. If it happens, get the title in any available language
diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp
index fc3e7ee..fd24e71 100644
--- a/src/plugins/NyaaSi.cpp
+++ b/src/plugins/NyaaSi.cpp
@@ -328,7 +328,7 @@ namespace QuickMedia {
std::string title;
BodyItems result_items;
- auto torrent_item = BodyItem::create("💾 Download magnet");
+ auto torrent_item = BodyItem::create("💾 Download");
std::string magnet_url;
std::string description;
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 1b46ed6..7552967 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -1883,7 +1883,7 @@ namespace QuickMedia {
return;
}
- YoutubeVideoPage::YoutubeVideoPage(Program *program, std::string url) : VideoPage(program, "") {
+ YoutubeVideoPage::YoutubeVideoPage(Program *program, std::string url, bool autoplay) : VideoPage(program, "", autoplay) {
set_url(std::move(url));
}