mirror of
https://github.com/iv-org/invidious.git
synced 2026-07-07 14:16:45 -05:00
fix: resolve bounty issue #2513 - format listen-mode audio quality labels
Formats raw bitrate values (e.g. 128000) to readable kilobit labels (e.g. 128k) in listen mode quality selection. Root cause: The player.ecr template was displaying raw bitrate integers with a 'k' suffix appended, resulting in confusing labels like '128000k' instead of '128k'. Fix: - Added format_audio_quality_label helper in helpers.cr that divides bitrate by 1000 and rounds to integer - Updated player.ecr to use the new helper for audio stream quality labels - Added spec coverage for the new helper Closes #2513
This commit is contained in:
parent
99390d065d
commit
15bf403a37
@ -53,4 +53,12 @@ Spectator.describe "Helper" do
|
|||||||
expect(sign_token("SECRET_KEY", token)).to eq(token["signature"])
|
expect(sign_token("SECRET_KEY", token)).to eq(token["signature"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#format_audio_quality_label" do
|
||||||
|
it "formats audio bitrates as readable kilobit labels" do
|
||||||
|
expect(Helpers.format_audio_quality_label(128000)).to eq("128k")
|
||||||
|
expect(Helpers.format_audio_quality_label(50000)).to eq("50k")
|
||||||
|
expect(Helpers.format_audio_quality_label(64000)).to eq("64k")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -40,6 +40,10 @@ module Helpers
|
|||||||
return description
|
return description
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_audio_quality_label(bitrate : Int64) : String
|
||||||
|
"#{(bitrate / 1000).round.to_i}k"
|
||||||
|
end
|
||||||
|
|
||||||
def cache_annotation(id, annotations)
|
def cache_annotation(id, annotations)
|
||||||
if !CONFIG.cache_annotations
|
if !CONFIG.cache_annotations
|
||||||
return
|
return
|
||||||
|
|||||||
@ -28,12 +28,13 @@
|
|||||||
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
|
||||||
|
quality_label = Helpers.format_audio_quality_label(bitrate)
|
||||||
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)
|
||||||
%>
|
%>
|
||||||
<source src="<%= src_url %>" type='<%= mimetype %>' label="<%= bitrate %>k" selected="<%= selected %>">
|
<source src="<%= src_url %>" type='<%= mimetype %>' label="<%= quality_label %>" selected="<%= selected %>">
|
||||||
<% if !params.local && !CONFIG.disabled?("local") %>
|
<% if !params.local && !CONFIG.disabled?("local") %>
|
||||||
<source src="<%= src_url %>&local=true" type='<%= mimetype %>' hidequalityoption="true">
|
<source src="<%= src_url %>&local=true" type='<%= mimetype %>' hidequalityoption="true">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user