From 63ceee7552487a6111f9bef460448f0bc3958607 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 11 Jun 2021 07:10:13 +0200 Subject: Fix youtube live streams (but they are slow...), fix youtube title spaces --- src/plugins/Youtube.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index d891ae3..8575d07 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -1834,6 +1834,11 @@ namespace QuickMedia { } std::string YoutubeVideoPage::get_video_url(int max_height, bool &has_embedded_audio) { + if(!hls_manifest_url.empty()) { + has_embedded_audio = true; + return hls_manifest_url; + } + if(video_formats.empty()) { has_embedded_audio = true; return ""; @@ -1858,6 +1863,7 @@ namespace QuickMedia { } PluginResult YoutubeVideoPage::load(std::string &title, std::string &channel_url) { + hls_manifest_url.clear(); video_formats.clear(); audio_formats.clear(); @@ -1898,16 +1904,23 @@ namespace QuickMedia { if(!streaming_data_json.isObject()) return PluginResult::ERR; - parse_formats(streaming_data_json); - - if(video_formats.empty() && audio_formats.empty()) - return PluginResult::ERR; + // TODO: Verify if this always works (what about copyrighted live streams?), also what about choosing video quality for live stream? + const Json::Value &hls_manifest_url_json = streaming_data_json["hlsManifestUrl"]; + if(hls_manifest_url_json.isString()) { + hls_manifest_url = hls_manifest_url_json.asString(); + } else { + parse_formats(streaming_data_json); + if(video_formats.empty() && audio_formats.empty()) + return PluginResult::ERR; + } 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()) + if(title_json.isString()) { title = title_json.asString(); + string_replace_all(title, '+', ' '); + } const Json::Value &channel_id_json = video_details_json["channelId"]; if(channel_id_json.isString()) -- cgit v1.2.3