aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Youtube.cpp107
1 files changed, 28 insertions, 79 deletions
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index f3226de..0c9580f 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -2396,11 +2396,7 @@ namespace QuickMedia {
}
std::string YoutubeVideoPage::get_video_url(int max_height, bool &has_embedded_audio, std::string &ext) {
- has_embedded_audio = true;
- ext = ".mp4";
- return url;
-#if 0
- if(!livestream_url.empty()) {
+ if(!livestream_url.empty() && video_formats.empty() && audio_formats.empty()) {
has_embedded_audio = true;
return livestream_url;
}
@@ -2432,7 +2428,23 @@ namespace QuickMedia {
ext = ".webm";
return chosen_video_format->base.url;
-#endif
+ }
+
+ std::string YoutubeVideoPage::get_audio_url(std::string &ext) {
+ if(audio_formats.empty())
+ return "";
+
+ const YoutubeAudioFormat *chosen_audio_format = &audio_formats.front();
+ fprintf(stderr, "Choosing youtube audio format: bitrate: %d, mime type: %s\n", chosen_audio_format->base.bitrate, chosen_audio_format->base.mime_type.c_str());
+
+ if(chosen_audio_format->base.mime_type.find("mp4") != std::string::npos)
+ ext = ".m4a";
+ else if(chosen_audio_format->base.mime_type.find("webm") != std::string::npos)
+ ext = ".opus"; // TODO: Detect if vorbis (.ogg) or opus (.opus)
+ else if(chosen_audio_format->base.mime_type.find("opus") != std::string::npos)
+ ext = ".opus";
+
+ return chosen_audio_format->base.url;
}
// Returns -1 if timestamp is in an invalid format
@@ -2532,8 +2544,10 @@ namespace QuickMedia {
static void subtitle_url_set_vtt_format(std::string &subtitle_url) {
const size_t index = subtitle_url.find("&fmt=");
- if(index == std::string::npos)
+ if(index == std::string::npos) {
+ subtitle_url += "&fmt=vtt";
return;
+ }
size_t end_index = subtitle_url.find('&');
if(end_index == std::string::npos)
@@ -2622,11 +2636,9 @@ namespace QuickMedia {
}
*/
- if(livestream_url.empty()) {
- parse_formats(*streaming_data_json);
- if(video_formats.empty() && audio_formats.empty())
- return PluginResult::ERR;
- }
+ parse_formats(*streaming_data_json);
+ if(video_formats.empty() && audio_formats.empty() && livestream_url.empty())
+ return PluginResult::ERR;
const Json::Value &video_details_json = json_root["videoDetails"];
if(video_details_json.isObject()) {
@@ -2715,82 +2727,19 @@ namespace QuickMedia {
// The second one works for age restricted videos and regular videos but only if they can be embedded. It doesn't work for copyrighted videos.
// The third one works for all non-copyrighted, non-age restricted videos, embeddable or not.
- const int num_request_types = 3;
+ const int num_request_types = 1;
std::string request_data[num_request_types] = {
R"END(
-{
- "context": {
- "client": {
- "clientName": "ANDROID",
- "clientVersion": "16.20",
- "hl": "en",
- "clientScreen": "EMBED"
- },
- "thirdParty": {
- "embedUrl": "https://google.com"
- }
- },
- "videoId": "%VIDEO_ID%",
- "playbackContext": {
- "contentPlaybackContext": {
- "html5Preference": "HTML5_PREF_WANTS"
- }
- },
- "contentCheckOk": true,
- "racyCheckOk": true
-}
-)END",
-R"END(
-{
- "context": {
- "client": {
- "clientName": "TVHTML5_SIMPLY_EMBEDDED_PLAYER",
- "clientVersion": "2.0",
- "hl": "en"
- },
- "thirdParty": {
- "embedUrl": "https://youtube.com/"
- }
- },
- "videoId": "%VIDEO_ID%",
- "contentCheckOk": true,
- "racyCheckOk": true
-}
-)END",
-R"END(
-{
- "context": {
- "client": {
- "clientName": "ANDROID",
- "clientVersion": "16.20",
- "hl": "en"
- },
- "thirdParty": {
- "embedUrl": "https://google.com"
- }
- },
- "videoId": "%VIDEO_ID%",
- "playbackContext": {
- "contentPlaybackContext": {
- "html5Preference": "HTML5_PREF_WANTS"
- }
- },
- "contentCheckOk": true,
- "racyCheckOk": true
-}
+ {"context":{"client":{"hl":"en","gl":"US","clientName":"IOS","clientVersion":"17.33.2","deviceModel":"iPhone14,3"}},"videoId":"%VIDEO_ID%"}
)END",
};
std::string client_names[num_request_types] = {
- "3",
- "85",
- "3"
+ "1"
};
std::string client_versions[num_request_types] = {
- "16.20",
- "2.0",
- "16.20"
+ "2.20210622.10.00"
};
for(int i = 0; i < num_request_types; ++i) {