aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-11 07:10:13 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-11 07:10:13 +0200
commit63ceee7552487a6111f9bef460448f0bc3958607 (patch)
tree366df41649e87afdf67f33c4dd0f3f26f6ad45b8
parent8ad3f9ab8cc7029eb5db937e229d2a37b51a3462 (diff)
Fix youtube live streams (but they are slow...), fix youtube title spaces
-rw-r--r--TODO3
-rw-r--r--plugins/Youtube.hpp1
-rw-r--r--src/plugins/Youtube.cpp23
3 files changed, 21 insertions, 6 deletions
diff --git a/TODO b/TODO
index 26d4b14..4a23870 100644
--- a/TODO
+++ b/TODO
@@ -161,4 +161,5 @@ Completely remove youtube-dl dependency (or at least for downloading videos/musi
Add loading of english subtitles for youtube.
Cancel search when new search happens.
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
+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).
+Improve live stream startup time by downloading the video formats in parts instead of the hls manifest? \ No newline at end of file
diff --git a/plugins/Youtube.hpp b/plugins/Youtube.hpp
index 9a0353e..7a6ea00 100644
--- a/plugins/Youtube.hpp
+++ b/plugins/Youtube.hpp
@@ -148,6 +148,7 @@ namespace QuickMedia {
private:
std::string xsrf_token;
std::string comments_continuation_token;
+ std::string hls_manifest_url;
std::vector<YoutubeVideoFormat> video_formats;
std::vector<YoutubeAudioFormat> audio_formats;
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())