Fix Style/VariableNames issues

This commit is contained in:
syeopite
2021-09-24 19:15:23 -07:00
parent 20cb751ff6
commit 35d15c7c2b
9 changed files with 42 additions and 41 deletions

View File

@@ -58,7 +58,7 @@ module Invidious::Routes::API::V1::Videos
captions.each do |caption|
json.object do
json.field "label", caption.name
json.field "languageCode", caption.languageCode
json.field "languageCode", caption.language_code
json.field "url", "/api/v1/captions/#{id}?label=#{URI.encode_www_form(caption.name)}"
end
end
@@ -73,7 +73,7 @@ module Invidious::Routes::API::V1::Videos
env.response.content_type = "text/vtt; charset=UTF-8"
if lang
caption = captions.select { |caption| caption.languageCode == lang }
caption = captions.select { |caption| caption.language_code == lang }
else
caption = captions.select { |caption| caption.name == label }
end
@@ -84,7 +84,7 @@ module Invidious::Routes::API::V1::Videos
caption = caption[0]
end
url = URI.parse("#{caption.baseUrl}&tlang=#{tlang}").request_target
url = URI.parse("#{caption.base_url}&tlang=#{tlang}").request_target
# Auto-generated captions often have cues that aren't aligned properly with the video,
# as well as some other markup that makes it cumbersome, so we try to fix that here
@@ -96,7 +96,7 @@ module Invidious::Routes::API::V1::Videos
str << <<-END_VTT
WEBVTT
Kind: captions
Language: #{tlang || caption.languageCode}
Language: #{tlang || caption.language_code}
END_VTT

View File

@@ -168,11 +168,11 @@ module Invidious::Routes::Embed
preferred_captions = captions.select { |caption|
params.preferred_captions.includes?(caption.name) ||
params.preferred_captions.includes?(caption.languageCode.split("-")[0])
params.preferred_captions.includes?(caption.language_code.split("-")[0])
}
preferred_captions.sort_by! { |caption|
(params.preferred_captions.index(caption.name) ||
params.preferred_captions.index(caption.languageCode.split("-")[0])).not_nil!
params.preferred_captions.index(caption.language_code.split("-")[0])).not_nil!
}
captions = captions - preferred_captions

View File

@@ -153,11 +153,11 @@ module Invidious::Routes::Watch
preferred_captions = captions.select { |caption|
params.preferred_captions.includes?(caption.name) ||
params.preferred_captions.includes?(caption.languageCode.split("-")[0])
params.preferred_captions.includes?(caption.language_code.split("-")[0])
}
preferred_captions.sort_by! { |caption|
(params.preferred_captions.index(caption.name) ||
params.preferred_captions.index(caption.languageCode.split("-")[0])).not_nil!
params.preferred_captions.index(caption.language_code.split("-")[0])).not_nil!
}
captions = captions - preferred_captions