diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-05-31 04:33:28 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-05-31 04:33:28 +0200 |
commit | 3586e3b510ef6828ab44dad1467f18ef4f2d7e2b (patch) | |
tree | 5e9eed17378fe65ef594cdac55acd5899b66ae8a /src/plugins | |
parent | 6e9bfd6571adf151e4e7fe4cb63f731314ebeff6 (diff) |
Youtube: merge search page and recommended page (show recommended if search field empty)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Youtube.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 3177f4d..65db3b1 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -9,6 +9,7 @@ #include "../../include/Theme.hpp" #include "../../include/Config.hpp" #include "../../plugins/WatchProgress.hpp" +#include "../../include/QuickMedia.hpp" #include <optional> #include <json/reader.h> extern "C" { @@ -784,8 +785,14 @@ namespace QuickMedia { } SearchResult YoutubeSearchPage::search(const std::string &str, BodyItems &result_items) { - if(str.empty()) + continuation_token.clear(); + current_page = 0; + added_videos.clear(); + + if(str.empty()) { + program->fill_recommended_items_from_json("youtube", program->load_recommended_json("youtube"), result_items); return SearchResult::OK; + } // TODO: Find this search url from youtube.com/... searchbox.js, and the url to that script from youtube.com/ html std::string url = "https://suggestqueries-clients6.youtube.com/complete/search?client=youtube&hl=en&gl=us&sugexp=rdcfrc%2Ccfro%3D1%2Cfp.cfr%3D1&gs_rn=64&gs_ri=youtube&ds=yt&cp=34&gs_id=f&xhr=t&xssi=t&q="; @@ -929,7 +936,11 @@ namespace QuickMedia { return PluginResult::OK; } - PluginResult YoutubeSearchPage::lazy_fetch(BodyItems&) { + PluginResult YoutubeSearchPage::lazy_fetch(BodyItems &result_items) { + continuation_token.clear(); + current_page = 0; + added_videos.clear(); + program->fill_recommended_items_from_json("youtube", program->load_recommended_json("youtube"), result_items); get_cookies(); return PluginResult::OK; } |