aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Youtube.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index ce359d4..338ada9 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -1833,6 +1833,10 @@ namespace QuickMedia {
return url.substr(index, end - index);
}
+ static void print_chosen_format(const YoutubeVideoFormat &format) {
+ fprintf(stderr, "Choosing youtube video format: width: %d, height: %d, fps: %d, bitrate: %d, mime type: %s\n", format.width, format.height, format.fps, format.base.bitrate, format.base.mime_type.c_str());
+ }
+
std::string YoutubeVideoPage::get_video_url(int max_height, bool &has_embedded_audio) {
if(!hls_manifest_url.empty()) {
has_embedded_audio = true;
@@ -1845,12 +1849,14 @@ namespace QuickMedia {
}
for(const auto &video_format : video_formats) {
- if(video_format.height <= max_height) {
+ if(video_format.height <= max_height && (video_format.base.mime_type.find("mp4") == std::string::npos || video_format.base.mime_type.find("av01") == std::string::npos)) {
+ print_chosen_format(video_format);
has_embedded_audio = video_format.has_embedded_audio;
return video_format.base.url;
}
}
+ print_chosen_format(video_formats.back());
has_embedded_audio = video_formats.back().has_embedded_audio;
return video_formats.back().base.url;
}
@@ -2060,18 +2066,23 @@ namespace QuickMedia {
}
}
+ // TODO: Support HDR?
+ const Json::Value &quality_label_json = format["qualityLabel"];
+ if(quality_label_json.isString() && strstr(quality_label_json.asCString(), "HDR")) continue;
+
YoutubeFormat youtube_format_base;
const Json::Value &mime_type_json = format["mimeType"];
if(!mime_type_json.isString()) continue;
+ youtube_format_base.mime_type = mime_type_json.asString();
const Json::Value &bitrate_json = format["bitrate"];
if(!bitrate_json.isInt()) continue;
youtube_format_base.bitrate = bitrate_json.asInt();
- if(strncmp(mime_type_json.asCString(), "video/", 6) == 0) {
+ if(strncmp(youtube_format_base.mime_type.c_str(), "video/", 6) == 0) {
bool has_embedded_audio = false;
- const char *codecs_p = strstr(mime_type_json.asCString(), "codecs=\"");
+ const char *codecs_p = strstr(youtube_format_base.mime_type.c_str(), "codecs=\"");
if(codecs_p) {
codecs_p += 8;
const char *codecs_sep_p = strchr(codecs_p, ',');
@@ -2104,7 +2115,7 @@ namespace QuickMedia {
}
video_formats.push_back(std::move(video_format));
- } else if(strncmp(mime_type_json.asCString(), "audio/", 6) == 0) {
+ } else if(strncmp(youtube_format_base.mime_type.c_str(), "audio/", 6) == 0) {
YoutubeAudioFormat audio_format;
audio_format.base = std::move(youtube_format_base);