@@ -111,16 +111,17 @@ def extract_video_info(video_id : String)
111
111
if ! CONFIG .invidious_companion.present?
112
112
if player_response.dig?(" streamingData" , " adaptiveFormats" , 0 , " url" ).nil?
113
113
LOGGER .warn(" Missing URLs for adaptive formats, falling back to other YT clients." )
114
- players_fallback = {YoutubeAPI ::ClientType ::TvHtml5 , YoutubeAPI ::ClientType ::WebMobile }
114
+ players_fallback = {YoutubeAPI ::ClientType ::TvSimply , YoutubeAPI ::ClientType ::WebMobile }
115
115
116
116
players_fallback.each do |player_fallback |
117
117
client_config.client_type = player_fallback
118
118
119
119
next if ! (player_fallback_response = try_fetch_streaming_data(video_id, client_config))
120
120
121
- if player_fallback_response.dig?(" streamingData" , " adaptiveFormats" , 0 , " url" )
121
+ adaptive_formats = player_fallback_response.dig?(" streamingData" , " adaptiveFormats" )
122
+ if adaptive_formats && (adaptive_formats.dig?(0 , " url" ) || adaptive_formats.dig?(0 , " signatureCipher" ))
122
123
streaming_data = player_response[" streamingData" ].as_h
123
- streaming_data[" adaptiveFormats" ] = player_fallback_response[ " streamingData " ][ " adaptiveFormats " ]
124
+ streaming_data[" adaptiveFormats" ] = adaptive_formats
124
125
player_response[" streamingData" ] = JSON ::Any .new(streaming_data)
125
126
break
126
127
end
@@ -146,7 +147,11 @@ def extract_video_info(video_id : String)
146
147
if streaming_data = player_response[" streamingData" ]?
147
148
%w[formats adaptiveFormats] .each do |key |
148
149
streaming_data.as_h[key]?.try & .as_a.each do |format |
149
- format.as_h[" url" ] = JSON ::Any .new(convert_url(format))
150
+ format = format.as_h
151
+ if format[" url" ]?.nil?
152
+ format[" url" ] = format[" signatureCipher" ]
153
+ end
154
+ format[" url" ] = JSON ::Any .new(convert_url(format))
150
155
end
151
156
end
152
157
0 commit comments