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