diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-06-11 06:52:04 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-06-11 06:52:04 +0200 |
commit | 8ad3f9ab8cc7029eb5db937e229d2a37b51a3462 (patch) | |
tree | 3b6592c16a6986aba818522c532768983a959388 | |
parent | 6443ce7df2d690c5a03dc68cb6866f5d7d4e3fba (diff) |
Readd youtube video title
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | plugins/Page.hpp | 2 | ||||
-rw-r--r-- | plugins/Youtube.hpp | 2 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 8 | ||||
-rw-r--r-- | src/VideoPlayer.cpp | 25 | ||||
-rw-r--r-- | src/plugins/Youtube.cpp | 6 |
6 files changed, 29 insertions, 15 deletions
@@ -160,6 +160,5 @@ Add keybinding to view file-manager images in fullscreen to preview them. Also a Completely remove youtube-dl dependency (or at least for downloading videos/music). Add loading of english subtitles for youtube. Cancel search when new search happens. -Set mpv title to the youtube video title (that we got from GET watch?v when fetching url). Update item height when it switches from not being merged with previous to being merged with previous. This happens when loading previous messages in matrix and the message is the top one. Reload youtube video url if the video is idle for too long. The video url is only valid for a specific amount of time (the valid duration is in the json).
\ No newline at end of file diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 0654fa7..0ed4933 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -124,7 +124,7 @@ namespace QuickMedia { virtual std::string get_audio_url() { return ""; } virtual std::string url_get_playable_url(const std::string &url) { return url; } virtual bool video_should_be_skipped(const std::string &url) { (void)url; return false; } - virtual PluginResult load(std::string &channel_url) { (void)channel_url; return PluginResult::OK; } + virtual PluginResult load(std::string &title, std::string &channel_url) { (void)title; (void)channel_url; return PluginResult::OK; } virtual void mark_watched() {}; protected: std::string url; diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp index 20c04fc..9a0353e 100644 --- a/plugins/Youtube.hpp +++ b/plugins/Youtube.hpp @@ -140,7 +140,7 @@ namespace QuickMedia { std::unique_ptr<Page> create_channels_page(Program *program, const std::string &channel_url) override; std::string get_video_url(int max_height, bool &has_embedded_audio) override; std::string get_audio_url() override; - PluginResult load(std::string &channel_url) override; + PluginResult load(std::string &title, std::string &channel_url) override; void mark_watched() override; private: void parse_format(const Json::Value &format_json, bool is_adaptive); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 4b78117..776f70f 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -2379,10 +2379,14 @@ namespace QuickMedia { video_loaded = false; video_player_window = None; - TaskResult load_result = run_task_with_loading_screen([video_page, &channel_url]() { - return video_page->load(channel_url) == PluginResult::OK; + std::string new_title; + TaskResult load_result = run_task_with_loading_screen([video_page, &new_title, &channel_url]() { + return video_page->load(new_title, channel_url) == PluginResult::OK; }); + if(!new_title.empty()) + video_title = std::move(new_title); + if(load_result == TaskResult::CANCEL) { current_page = previous_page; return; diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 2b0653c..4fce4e0 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -80,7 +80,7 @@ namespace QuickMedia { return result; } - VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, const std::string &plugin_name, const std::string &) { + VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, const std::string &plugin_name, const std::string &title) { parent_window = _parent_window; if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == -1) { @@ -160,14 +160,21 @@ namespace QuickMedia { }); } - std::string ytdl_options_arg; - if(plugin_name.empty()) { - ytdl_options_arg = "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub="; - args.push_back(ytdl_options_arg.c_str()); - } else { - ytdl_options_arg = "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=,mark-watched=,cookies=\"" + escape_quotes(cookies_filepath.data) + "\""; - args.push_back(ytdl_options_arg.c_str()); - } + //std::string ytdl_options_arg; + //if(plugin_name.empty()) { + // ytdl_options_arg = "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub="; + // args.push_back(ytdl_options_arg.c_str()); + //} else { + // ytdl_options_arg = "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=,mark-watched=,cookies=\"" + escape_quotes(cookies_filepath.data) + "\""; + // args.push_back(ytdl_options_arg.c_str()); + //} + + std::string force_media_title_arg; + if(!title.empty()) + force_media_title_arg = "--force-media-title=" + title; + + if(!force_media_title_arg.empty()) + args.push_back(force_media_title_arg.c_str()); if(no_video) args.push_back("--no-video"); diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 04c29e0..d891ae3 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -1857,7 +1857,7 @@ namespace QuickMedia { return audio_formats.front().base.url; } - PluginResult YoutubeVideoPage::load(std::string &channel_url) { + PluginResult YoutubeVideoPage::load(std::string &title, std::string &channel_url) { video_formats.clear(); audio_formats.clear(); @@ -1905,6 +1905,10 @@ namespace QuickMedia { const Json::Value &video_details_json = json_root["videoDetails"]; if(video_details_json.isObject()) { + const Json::Value &title_json = video_details_json["title"]; + if(title_json.isString()) + title = title_json.asString(); + const Json::Value &channel_id_json = video_details_json["channelId"]; if(channel_id_json.isString()) channel_url = "https://www.youtube.com/channel/" + channel_id_json.asString(); |