aboutsummaryrefslogtreecommitdiff
path: root/plugins/Youtube.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Youtube.hpp')
-rw-r--r--plugins/Youtube.hpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp
index 746619c..dea6cc2 100644
--- a/plugins/Youtube.hpp
+++ b/plugins/Youtube.hpp
@@ -5,14 +5,35 @@
#include <unordered_set>
namespace QuickMedia {
- class YoutubeSearchPage : public Page {
+ struct YoutubeFormat {
+ std::string url;
+ int bitrate = 0;
+ };
+
+ struct YoutubeVideoFormat {
+ YoutubeFormat base;
+ int width = 0;
+ int height = 0;
+ int fps = 0;
+ bool has_embedded_audio = false;
+ };
+
+ struct YoutubeAudioFormat {
+ YoutubeFormat base;
+ };
+
+ bool youtube_url_extract_id(const std::string &youtube_url, std::string &youtube_video_id);
+
+ class YoutubeSearchPage : public LazyFetchPage {
public:
- YoutubeSearchPage(Program *program) : Page(program) {}
+ YoutubeSearchPage(Program *program) : LazyFetchPage(program) {}
const char* get_title() const override { return "Search"; }
bool search_is_filter() override { return false; }
SearchResult search(const std::string &str, BodyItems &result_items) override;
PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ PluginResult lazy_fetch(BodyItems &result_items) override;
+ bool lazy_fetch_is_loader() override { return true; }
private:
PluginResult search_get_continuation(const std::string &url, const std::string &continuation_token, BodyItems &result_items);
private:
@@ -110,18 +131,24 @@ namespace QuickMedia {
class YoutubeVideoPage : public VideoPage {
public:
- YoutubeVideoPage(Program *program, const std::string &url) : VideoPage(program), url(url) {}
+ YoutubeVideoPage(Program *program, std::string url) : VideoPage(program, std::move(url)) {}
const char* get_title() const override { return ""; }
BodyItems get_related_media(const std::string &url, std::string &channel_url) override;
std::unique_ptr<Page> create_search_page(Program *program, int &search_delay) override;
std::unique_ptr<Page> create_comments_page(Program *program) override;
- std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program, const std::string &video_url, const std::string &video_title) override;
+ std::unique_ptr<RelatedVideosPage> create_related_videos_page(Program *program) override;
std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) override;
- std::string get_url() override { return url; }
+ std::string get_video_url(int max_height, bool &has_embedded_audio) override;
+ std::string get_audio_url() override;
+ PluginResult load() override;
+ private:
+ void parse_format(const Json::Value &format_json, bool is_adaptive);
+ void parse_formats(const Json::Value &streaming_data_json);
private:
std::string xsrf_token;
std::string comments_continuation_token;
- std::string url;
+ std::vector<YoutubeVideoFormat> video_formats;
+ std::vector<YoutubeAudioFormat> audio_formats;
std::string playback_url;
std::string watchtime_url;