mirror of
https://github.com/iv-org/invidious.git
synced 2026-06-15 03:16:46 -05:00
Fix listen mode audio bitrate labels
This commit is contained in:
parent
0e0ee40cb6
commit
db45f93bee
@ -167,9 +167,13 @@ module Invidious::Routes::Watch
|
||||
url = audio_streams[0]["url"].as_s
|
||||
|
||||
if params.quality.ends_with? "k"
|
||||
requested_audio_bitrate = params.quality.rchop("k").to_i?
|
||||
audio_streams.each do |fmt|
|
||||
if fmt["bitrate"].as_i == params.quality.rchop("k").to_i
|
||||
url = fmt["url"].as_s
|
||||
if requested_audio_bitrate
|
||||
bitrate = fmt["bitrate"].as_i
|
||||
if (bitrate / 1000).round.to_i == requested_audio_bitrate || bitrate == requested_audio_bitrate
|
||||
url = fmt["url"].as_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -14,12 +14,18 @@
|
||||
<% # default to 128k m4a stream
|
||||
best_m4a_stream_index = 0
|
||||
best_m4a_stream_bitrate = 0
|
||||
requested_audio_bitrate = params.quality.ends_with?("k") ? params.quality.rchop("k").to_i? : nil
|
||||
audio_streams.each_with_index do |fmt, i|
|
||||
bandwidth = fmt["bitrate"].as_i
|
||||
if (fmt["mimeType"].as_s.starts_with?("audio/mp4") && bandwidth > best_m4a_stream_bitrate)
|
||||
best_m4a_stream_bitrate = bandwidth
|
||||
best_m4a_stream_index = i
|
||||
end
|
||||
if requested_audio_bitrate
|
||||
if (bandwidth / 1000).round.to_i == requested_audio_bitrate || bandwidth == requested_audio_bitrate
|
||||
best_m4a_stream_index = i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
audio_streams.each_with_index do |fmt, i|
|
||||
@ -28,7 +34,7 @@
|
||||
src_url = invidious_companion.public_url.to_s + src_url +
|
||||
"&check=#{invidious_companion_check_id}" if (invidious_companion)
|
||||
|
||||
bitrate = fmt["bitrate"]
|
||||
bitrate = (fmt["bitrate"].as_i / 1000).round.to_i
|
||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||
|
||||
selected = (i == best_m4a_stream_index)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user