Merge ea0f99b74156276ef9fc7ddc10b694d47eac6217 into 9eda6e5bc433638ee251e06d05daff3fdd12ca86

This commit is contained in:
JasonDavis666 2026-04-26 22:19:06 +08:00 committed by GitHub
commit dbce005502
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View File

@ -31,6 +31,13 @@ Spectator.describe "Helper" do
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")
end
end
describe "#sign_token" do
it "correctly signs a given hash" do
token = {

View File

@ -40,6 +40,10 @@ module Helpers
return description
end
def format_audio_quality_label(bitrate : Int) : String
"#{(bitrate / 1000).round.to_i}k"
end
def cache_annotation(id, annotations)
if !CONFIG.cache_annotations
return

View File

@ -28,12 +28,13 @@
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
quality_label = Helpers.format_audio_quality_label(bitrate)
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="<%= quality_label %>" selected="<%= selected %>">
<% if !params.local && !CONFIG.disabled?("local") %>
<source src="<%= src_url %>&local=true" type='<%= mimetype %>' hidequalityoption="true">
<% end %>