use web screen embed for fixing potoken functionality (#4923)

* use web screen embed for fixing potoken functionality

* use web screen embed only for getting streamingData + disable tv screen on po_token
This commit is contained in:
Émilien (perso) 2024-09-16 23:42:43 +02:00 committed by GitHub
parent 4782a67038
commit de918b9234
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -102,6 +102,12 @@ def extract_video_info(video_id : String)
new_player_response = nil new_player_response = nil
# Use the WEB embed client when po_token is configured because it only works on this client
if CONFIG.po_token
client_config.client_type = YoutubeAPI::ClientType::WebEmbeddedPlayer
new_player_response = try_fetch_streaming_data(video_id, client_config)
end
# Don't use Android client if po_token is passed because po_token doesn't # Don't use Android client if po_token is passed because po_token doesn't
# work for Android client. # work for Android client.
if reason.nil? && CONFIG.po_token.nil? if reason.nil? && CONFIG.po_token.nil?
@ -114,10 +120,9 @@ def extract_video_info(video_id : String)
end end
# Last hope # Last hope
# Only trigger if reason found and po_token or didn't work wth Android client. # Only trigger if reason found or didn't work wth Android client.
# TvHtml5ScreenEmbed now requires sig helper for it to work but po_token is not required # TvHtml5ScreenEmbed now requires sig helper for it to work but doesn't work with po_token.
# if the IP address is not blocked. if reason && CONFIG.po_token.nil?
if CONFIG.po_token && reason || CONFIG.po_token.nil? && new_player_response.nil?
client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed
new_player_response = try_fetch_streaming_data(video_id, client_config) new_player_response = try_fetch_streaming_data(video_id, client_config)
end end

View file

@ -291,8 +291,9 @@ module YoutubeAPI
end end
if client_config.screen == "EMBED" if client_config.screen == "EMBED"
# embedUrl https://www.google.com allow loading video that are configured not embeddable
client_context["thirdParty"] = { client_context["thirdParty"] = {
"embedUrl" => "https://www.youtube.com/embed/#{video_id}", "embedUrl" => "https://www.google.com/",
} of String => String | Int64 } of String => String | Int64
end end