mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 07:48:31 -06:00
Fix Style/ParenthesesAroundCondition type of Ameba issues
This commit is contained in:
parent
818d4266a7
commit
ca41bbd21b
@ -31,9 +31,6 @@ Lint/SpecFilename:
|
|||||||
# Style
|
# Style
|
||||||
#
|
#
|
||||||
|
|
||||||
Style/ParenthesesAroundCondition:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# This requires a rewrite of most data structs (and their usage) in Invidious.
|
# This requires a rewrite of most data structs (and their usage) in Invidious.
|
||||||
Naming/QueryBoolMethods:
|
Naming/QueryBoolMethods:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|||||||
@ -161,7 +161,7 @@ def get_about_info(ucid, locale) : AboutChannel
|
|||||||
|
|
||||||
sub_count = 0
|
sub_count = 0
|
||||||
|
|
||||||
if (metadata_rows = initdata.dig?("header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "metadata", "contentMetadataViewModel", "metadataRows").try &.as_a)
|
if metadata_rows = initdata.dig?("header", "pageHeaderRenderer", "content", "pageHeaderViewModel", "metadata", "contentMetadataViewModel", "metadataRows").try &.as_a
|
||||||
metadata_rows.each do |row|
|
metadata_rows.each do |row|
|
||||||
metadata_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("subscribers") }
|
metadata_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("subscribers") }
|
||||||
if !metadata_part.nil?
|
if !metadata_part.nil?
|
||||||
|
|||||||
@ -19,7 +19,7 @@ module Invidious::Frontend::ChannelPage
|
|||||||
|
|
||||||
TabsAvailable.each do |tab|
|
TabsAvailable.each do |tab|
|
||||||
# Ignore playlists, as it is not supported for auto-generated channels yet
|
# Ignore playlists, as it is not supported for auto-generated channels yet
|
||||||
next if (tab.playlists? && channel.auto_generated)
|
next if tab.playlists? && channel.auto_generated
|
||||||
|
|
||||||
tab_name = tab.to_s.downcase
|
tab_name = tab.to_s.downcase
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ module Invidious::Frontend::WatchPage
|
|||||||
end
|
end
|
||||||
|
|
||||||
url = "/download"
|
url = "/download"
|
||||||
if (CONFIG.invidious_companion.present?)
|
if CONFIG.invidious_companion.present?
|
||||||
invidious_companion = CONFIG.invidious_companion.sample
|
invidious_companion = CONFIG.invidious_companion.sample
|
||||||
url = "#{invidious_companion.public_url}/download?check=#{invidious_companion_encrypt(video.id)}"
|
url = "#{invidious_companion.public_url}/download?check=#{invidious_companion_encrypt(video.id)}"
|
||||||
end
|
end
|
||||||
|
|||||||
@ -294,12 +294,12 @@ module I18next::Plurals
|
|||||||
# Rule: (n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5)
|
# Rule: (n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5)
|
||||||
#
|
#
|
||||||
def self.special_arabic(count : Int) : UInt8
|
def self.special_arabic(count : Int) : UInt8
|
||||||
return count.to_u8 if (count == 0 || count == 1 || count == 2)
|
return count.to_u8 if count == 0 || count == 1 || count == 2
|
||||||
|
|
||||||
n_mod_100 = count % 100
|
n_mod_100 = count % 100
|
||||||
|
|
||||||
return 3_u8 if (n_mod_100 >= 3 && n_mod_100 <= 10)
|
return 3_u8 if n_mod_100 >= 3 && n_mod_100 <= 10
|
||||||
return 4_u8 if (n_mod_100 >= 11)
|
return 4_u8 if n_mod_100 >= 11
|
||||||
5_u8
|
5_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -309,8 +309,8 @@ module I18next::Plurals
|
|||||||
# Rule: ((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2)
|
# Rule: ((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2)
|
||||||
#
|
#
|
||||||
def self.special_czech_slovak(count : Int) : UInt8
|
def self.special_czech_slovak(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1)
|
return 0_u8 if count == 1
|
||||||
return 1_u8 if (count >= 2 && count <= 4)
|
return 1_u8 if count >= 2 && count <= 4
|
||||||
2_u8
|
2_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ module I18next::Plurals
|
|||||||
# Rule: (n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)
|
# Rule: (n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)
|
||||||
#
|
#
|
||||||
def self.special_polish_kashubian(count : Int) : UInt8
|
def self.special_polish_kashubian(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1)
|
return 0_u8 if count == 1
|
||||||
|
|
||||||
n_mod_10 = count % 10
|
n_mod_10 = count % 10
|
||||||
n_mod_100 = count % 100
|
n_mod_100 = count % 100
|
||||||
@ -338,9 +338,9 @@ module I18next::Plurals
|
|||||||
# Rule: ((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3)
|
# Rule: ((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3)
|
||||||
#
|
#
|
||||||
def self.special_welsh(count : Int) : UInt8
|
def self.special_welsh(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1)
|
return 0_u8 if count == 1
|
||||||
return 1_u8 if (count == 2)
|
return 1_u8 if count == 2
|
||||||
return 2_u8 if (count != 8 && count != 11)
|
return 2_u8 if count != 8 && count != 11
|
||||||
3_u8
|
3_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -350,10 +350,10 @@ module I18next::Plurals
|
|||||||
# Rule: (n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4)
|
# Rule: (n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4)
|
||||||
#
|
#
|
||||||
def self.special_irish(count : Int) : UInt8
|
def self.special_irish(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1)
|
return 0_u8 if count == 1
|
||||||
return 1_u8 if (count == 2)
|
return 1_u8 if count == 2
|
||||||
return 2_u8 if (count < 7)
|
return 2_u8 if count < 7
|
||||||
return 3_u8 if (count < 11)
|
return 3_u8 if count < 11
|
||||||
4_u8
|
4_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -363,9 +363,9 @@ module I18next::Plurals
|
|||||||
# Rule: ((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3)
|
# Rule: ((n==1 || n==11) ? 0 : (n==2 || n==12) ? 1 : (n > 2 && n < 20) ? 2 : 3)
|
||||||
#
|
#
|
||||||
def self.special_scottish_gaelic(count : Int) : UInt8
|
def self.special_scottish_gaelic(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1 || count == 11)
|
return 0_u8 if count == 1 || count == 11
|
||||||
return 1_u8 if (count == 2 || count == 12)
|
return 1_u8 if count == 2 || count == 12
|
||||||
return 2_u8 if (count > 2 && count < 20)
|
return 2_u8 if count > 2 && count < 20
|
||||||
3_u8
|
3_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -468,8 +468,8 @@ module I18next::Plurals
|
|||||||
return 1_u8 if count == 0
|
return 1_u8 if count == 0
|
||||||
|
|
||||||
n_mod_100 = count % 100
|
n_mod_100 = count % 100
|
||||||
return 1_u8 if (n_mod_100 > 1 && n_mod_100 < 11)
|
return 1_u8 if n_mod_100 > 1 && n_mod_100 < 11
|
||||||
return 2_u8 if (n_mod_100 > 10 && n_mod_100 < 20)
|
return 2_u8 if n_mod_100 > 10 && n_mod_100 < 20
|
||||||
3_u8
|
3_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ module I18next::Plurals
|
|||||||
return 1_u8 if count == 0
|
return 1_u8 if count == 0
|
||||||
|
|
||||||
n_mod_100 = count % 100
|
n_mod_100 = count % 100
|
||||||
return 1_u8 if (n_mod_100 > 0 && n_mod_100 < 20)
|
return 1_u8 if n_mod_100 > 0 && n_mod_100 < 20
|
||||||
2_u8
|
2_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -494,9 +494,9 @@ module I18next::Plurals
|
|||||||
#
|
#
|
||||||
def self.special_slovenian(count : Int) : UInt8
|
def self.special_slovenian(count : Int) : UInt8
|
||||||
n_mod_100 = count % 100
|
n_mod_100 = count % 100
|
||||||
return 1_u8 if (n_mod_100 == 1)
|
return 1_u8 if n_mod_100 == 1
|
||||||
return 2_u8 if (n_mod_100 == 2)
|
return 2_u8 if n_mod_100 == 2
|
||||||
return 3_u8 if (n_mod_100 == 3 || n_mod_100 == 4)
|
return 3_u8 if n_mod_100 == 3 || n_mod_100 == 4
|
||||||
0_u8
|
0_u8
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -506,8 +506,8 @@ module I18next::Plurals
|
|||||||
# Rule: (n==1 ? 0 : n==2 ? 1 : (n<0 || n>10) && n%10==0 ? 2 : 3)
|
# Rule: (n==1 ? 0 : n==2 ? 1 : (n<0 || n>10) && n%10==0 ? 2 : 3)
|
||||||
#
|
#
|
||||||
def self.special_hebrew(count : Int) : UInt8
|
def self.special_hebrew(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1)
|
return 0_u8 if count == 1
|
||||||
return 1_u8 if (count == 2)
|
return 1_u8 if count == 2
|
||||||
|
|
||||||
if (count < 0 || count > 10) && (count % 10) == 0
|
if (count < 0 || count > 10) && (count % 10) == 0
|
||||||
2_u8
|
2_u8
|
||||||
@ -535,9 +535,9 @@ module I18next::Plurals
|
|||||||
# This rule is mostly compliant to CLDR v42
|
# This rule is mostly compliant to CLDR v42
|
||||||
#
|
#
|
||||||
def self.special_cldr_spanish_italian(count : Int) : UInt8
|
def self.special_cldr_spanish_italian(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 1) # one
|
return 0_u8 if count == 1 # one
|
||||||
return 1_u8 if (count != 0 && count % 1_000_000 == 0) # many
|
return 1_u8 if count != 0 && count % 1_000_000 == 0 # many
|
||||||
2_u8 # other
|
2_u8 # other
|
||||||
end
|
end
|
||||||
|
|
||||||
# Plural form for French and Portuguese
|
# Plural form for French and Portuguese
|
||||||
@ -545,9 +545,9 @@ module I18next::Plurals
|
|||||||
# This rule is mostly compliant to CLDR v42
|
# This rule is mostly compliant to CLDR v42
|
||||||
#
|
#
|
||||||
def self.special_cldr_french_portuguese(count : Int) : UInt8
|
def self.special_cldr_french_portuguese(count : Int) : UInt8
|
||||||
return 0_u8 if (count == 0 || count == 1) # one
|
return 0_u8 if count == 0 || count == 1 # one
|
||||||
return 1_u8 if (count % 1_000_000 == 0) # many
|
return 1_u8 if count % 1_000_000 == 0 # many
|
||||||
2_u8 # other
|
2_u8 # other
|
||||||
end
|
end
|
||||||
|
|
||||||
# Plural form for Hungarian and Serbian
|
# Plural form for Hungarian and Serbian
|
||||||
@ -558,9 +558,9 @@ module I18next::Plurals
|
|||||||
n_mod_10 = count % 10
|
n_mod_10 = count % 10
|
||||||
n_mod_100 = count % 100
|
n_mod_100 = count % 100
|
||||||
|
|
||||||
return 0_u8 if (n_mod_10 == 1 && n_mod_100 != 11) # one
|
return 0_u8 if n_mod_10 == 1 && n_mod_100 != 11 # one
|
||||||
return 1_u8 if (2 <= n_mod_10 <= 4 && (n_mod_100 < 12 || 14 < n_mod_100)) # few
|
return 1_u8 if 2 <= n_mod_10 <= 4 && (n_mod_100 < 12 || 14 < n_mod_100) # few
|
||||||
2_u8 # other
|
2_u8 # other
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module Invidious::Routes::API::V1::Misc
|
|||||||
{"software" => SOFTWARE}.to_json
|
{"software" => SOFTWARE}.to_json
|
||||||
else
|
else
|
||||||
# Calculate playback success rate
|
# Calculate playback success rate
|
||||||
if (tracker = Invidious::Jobs::StatisticsRefreshJob::STATISTICS["playback"]?)
|
if tracker = Invidious::Jobs::StatisticsRefreshJob::STATISTICS["playback"]?
|
||||||
tracker = tracker.as(Hash(String, Int64 | Float64))
|
tracker = tracker.as(Hash(String, Int64 | Float64))
|
||||||
|
|
||||||
if !tracker.empty?
|
if !tracker.empty?
|
||||||
|
|||||||
@ -35,7 +35,7 @@ def fetch_trending(trending_type, region, locale)
|
|||||||
# Ignore the smaller categories, as they generally contain a sponsored
|
# Ignore the smaller categories, as they generally contain a sponsored
|
||||||
# channel, which brings a lot of noise on the trending page.
|
# channel, which brings a lot of noise on the trending page.
|
||||||
# See: https://github.com/iv-org/invidious/issues/2989
|
# See: https://github.com/iv-org/invidious/issues/2989
|
||||||
next if (itm.contents.size < 24 && deduplicate)
|
next if itm.contents.size < 24 && deduplicate
|
||||||
|
|
||||||
extracted.concat itm.contents.select(SearchItem)
|
extracted.concat itm.contents.select(SearchItem)
|
||||||
else
|
else
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
best_m4a_stream_bitrate = 0
|
best_m4a_stream_bitrate = 0
|
||||||
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
|
||||||
@ -26,7 +26,7 @@
|
|||||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||||
src_url += "&local=true" if params.local
|
src_url += "&local=true" if params.local
|
||||||
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"]
|
||||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||||
@ -42,7 +42,7 @@
|
|||||||
<% if params.quality == "dash"
|
<% if params.quality == "dash"
|
||||||
src_url = "/api/manifest/dash/id/" + video.id + "?local=true&unique_res=1"
|
src_url = "/api/manifest/dash/id/" + video.id + "?local=true&unique_res=1"
|
||||||
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
|
||||||
%>
|
%>
|
||||||
<source src="<%= src_url %>" type='application/dash+xml' label="dash">
|
<source src="<%= src_url %>" type='application/dash+xml' label="dash">
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||||
src_url += "&local=true" if params.local
|
src_url += "&local=true" if params.local
|
||||||
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
|
||||||
|
|
||||||
quality = fmt["quality"]
|
quality = fmt["quality"]
|
||||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||||
@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
<% preferred_captions.each do |caption|
|
<% preferred_captions.each do |caption|
|
||||||
api_captions_url = "/api/v1/captions/"
|
api_captions_url = "/api/v1/captions/"
|
||||||
api_captions_url = invidious_companion.public_url.to_s + api_captions_url if (invidious_companion)
|
api_captions_url = invidious_companion.public_url.to_s + api_captions_url if invidious_companion
|
||||||
api_captions_check_id = "&check=#{invidious_companion_check_id}"
|
api_captions_check_id = "&check=#{invidious_companion_check_id}"
|
||||||
%>
|
%>
|
||||||
<track kind="captions" src="<%= api_captions_url %><%= video.id %>?label=<%= caption.name %><%= api_captions_check_id %>" label="<%= caption.name %>">
|
<track kind="captions" src="<%= api_captions_url %><%= video.id %>?label=<%= caption.name %><%= api_captions_check_id %>" label="<%= caption.name %>">
|
||||||
@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
<% captions.each do |caption|
|
<% captions.each do |caption|
|
||||||
api_captions_url = "/api/v1/captions/"
|
api_captions_url = "/api/v1/captions/"
|
||||||
api_captions_url = invidious_companion.public_url.to_s + api_captions_url if (invidious_companion)
|
api_captions_url = invidious_companion.public_url.to_s + api_captions_url if invidious_companion
|
||||||
api_captions_check_id = "&check=#{invidious_companion_check_id}"
|
api_captions_check_id = "&check=#{invidious_companion_check_id}"
|
||||||
%>
|
%>
|
||||||
<track kind="captions" src="<%= api_captions_url %><%= video.id %>?label=<%= caption.name %><%= api_captions_check_id %>" label="<%= caption.name %>">
|
<track kind="captions" src="<%= api_captions_url %><%= video.id %>?label=<%= caption.name %><%= api_captions_check_id %>" label="<%= caption.name %>">
|
||||||
|
|||||||
@ -204,7 +204,7 @@ private module Parsers
|
|||||||
# TODO change default value to nil
|
# TODO change default value to nil
|
||||||
|
|
||||||
subscriber_count = item_contents.dig?("subscriberCountText", "simpleText").try &.as_s
|
subscriber_count = item_contents.dig?("subscriberCountText", "simpleText").try &.as_s
|
||||||
channel_handle = subscriber_count if (subscriber_count.try &.starts_with? "@")
|
channel_handle = subscriber_count if subscriber_count.try &.starts_with? "@"
|
||||||
|
|
||||||
# Since youtube added channel handles, `VideoCountText` holds the number of
|
# Since youtube added channel handles, `VideoCountText` holds the number of
|
||||||
# subscribers and `subscriberCountText` holds the handle, except when the
|
# subscribers and `subscriberCountText` holds the handle, except when the
|
||||||
|
|||||||
@ -78,7 +78,7 @@ module UrlSanitizer
|
|||||||
new_uri = URI.new(path: "/")
|
new_uri = URI.new(path: "/")
|
||||||
|
|
||||||
# Redirect to homepage for bogus URLs
|
# Redirect to homepage for bogus URLs
|
||||||
return new_uri if (unsafe_host.nil? || unsafe_path.nil?)
|
return new_uri if unsafe_host.nil? || unsafe_path.nil?
|
||||||
|
|
||||||
breadcrumbs = unsafe_path
|
breadcrumbs = unsafe_path
|
||||||
.split('/', remove_empty: true)
|
.split('/', remove_empty: true)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user