diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-06-02 00:05:37 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-06-02 00:05:37 +0200 |
commit | fe92e3fcf858fc71583cd1a52a25e1f62324f5b8 (patch) | |
tree | 45bc72fe600346087f2ebcf9b72e79159c7f3fb6 | |
parent | 223cdf22c5aec68d1e14bc013d8e75daa374d04e (diff) |
Play all videos in thread instead of exiting after playing the first one
-rw-r--r-- | plugins/Fourchan.hpp | 2 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 1 | ||||
-rw-r--r-- | src/plugins/Fourchan.cpp | 17 |
3 files changed, 19 insertions, 1 deletions
diff --git a/plugins/Fourchan.hpp b/plugins/Fourchan.hpp index 7b76f83..33c6579 100644 --- a/plugins/Fourchan.hpp +++ b/plugins/Fourchan.hpp @@ -21,6 +21,7 @@ namespace QuickMedia { int get_search_delay() const override { return 150; } Page get_page_after_search() const override { return Page::IMAGE_BOARD_THREAD_LIST; } bool search_is_filter() override { return true; } + BodyItems get_related_media(const std::string &url) override; private: PluginResult get_threads_internal(const std::string &url, BodyItems &result_items); void set_board_url(const std::string &new_url); @@ -38,5 +39,6 @@ namespace QuickMedia { std::condition_variable thread_list_update_cv; bool thread_list_cached = false; bool running = true; + std::vector<std::string> cached_media_urls; }; }
\ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 197425f..e2922c7 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1598,7 +1598,6 @@ namespace QuickMedia { body->reset_selected(); search_bar->clear(); } else if(event.key.code == sf::Keyboard::P) { - // TODO: Make this work when thumbnail is preview for a video/gif instead of a static image BodyItem *selected_item = body->get_selected(); if(selected_item && !selected_item->attached_content_url.empty()) { if(is_url_video(selected_item->attached_content_url)) { diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 1dfe681..e65835a 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -374,6 +374,7 @@ namespace QuickMedia { } PluginResult Fourchan::get_thread_comments(const std::string &list_url, const std::string &url, BodyItems &result_items) { + cached_media_urls.clear(); std::string server_response; if(download_to_string(fourchan_url + list_url + "/thread/" + url + ".json", server_response, {}, use_tor) != DownloadResult::OK) return PluginResult::NET_ERR; @@ -509,6 +510,7 @@ namespace QuickMedia { std::string tim_str = std::to_string(tim.asInt64()); body_item->thumbnail_url = fourchan_image_url + list_url + "/" + tim_str + "s.jpg"; body_item->attached_content_url = fourchan_image_url + list_url + "/" + tim_str + ext_str; + cached_media_urls.push_back(body_item->attached_content_url); } ++body_item_index; @@ -547,4 +549,19 @@ namespace QuickMedia { return PostResult::TRY_AGAIN; return PostResult::ERR; } + + BodyItems Fourchan::get_related_media(const std::string &url) { + BodyItems body_items; + auto it = cached_media_urls.begin(); + for(; it != cached_media_urls.end(); ++it) { + if(url == *it) + break; + } + for(; it != cached_media_urls.end(); ++it) { + auto body_item = std::make_unique<BodyItem>(""); + body_item->url = *it; + body_items.push_back(std::move(body_item)); + } + return body_items; + } }
\ No newline at end of file |