Fix listen mode quality labels showing raw bitrate values

YouTube audio stream bitrates are in bps; display kbps in the player
source labels and match quality selection for both bps and kbps values.

Fixes #2513

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pc-style 2026-05-31 01:51:20 +02:00
parent 0e0ee40cb6
commit c66fff8415
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View File

@ -167,8 +167,10 @@ module Invidious::Routes::Watch
url = audio_streams[0]["url"].as_s
if params.quality.ends_with? "k"
target = params.quality.rchop("k").to_i
audio_streams.each do |fmt|
if fmt["bitrate"].as_i == params.quality.rchop("k").to_i
bitrate = fmt["bitrate"].as_i
if bitrate == target || bitrate // 1000 == target
url = fmt["url"].as_s
end
end

View File

@ -28,12 +28,12 @@
src_url = invidious_companion.public_url.to_s + src_url +
"&check=#{invidious_companion_check_id}" if (invidious_companion)
bitrate = fmt["bitrate"]
bitrate_kbps = fmt["bitrate"].as_i // 1000
mimetype = HTML.escape(fmt["mimeType"].as_s)
selected = (i == best_m4a_stream_index)
%>
<source src="<%= src_url %>" type='<%= mimetype %>' label="<%= bitrate %>k" selected="<%= selected %>">
<source src="<%= src_url %>" type='<%= mimetype %>' label="<%= bitrate_kbps %>k" selected="<%= selected %>">
<% if !params.local && !CONFIG.disabled?("local") %>
<source src="<%= src_url %>&local=true" type='<%= mimetype %>' hidequalityoption="true">
<% end %>