mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 15:58:30 -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/ParenthesesAroundCondition:
|
||||
Enabled: false
|
||||
|
||||
# This requires a rewrite of most data structs (and their usage) in Invidious.
|
||||
Naming/QueryBoolMethods:
|
||||
Enabled: false
|
||||
|
||||
@ -161,7 +161,7 @@ def get_about_info(ucid, locale) : AboutChannel
|
||||
|
||||
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_part = row.dig?("metadataParts").try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("subscribers") }
|
||||
if !metadata_part.nil?
|
||||
|
||||
@ -19,7 +19,7 @@ module Invidious::Frontend::ChannelPage
|
||||
|
||||
TabsAvailable.each do |tab|
|
||||
# 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
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ module Invidious::Frontend::WatchPage
|
||||
end
|
||||
|
||||
url = "/download"
|
||||
if (CONFIG.invidious_companion.present?)
|
||||
if CONFIG.invidious_companion.present?
|
||||
invidious_companion = CONFIG.invidious_companion.sample
|
||||
url = "#{invidious_companion.public_url}/download?check=#{invidious_companion_encrypt(video.id)}"
|
||||
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)
|
||||
#
|
||||
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
|
||||
|
||||
return 3_u8 if (n_mod_100 >= 3 && n_mod_100 <= 10)
|
||||
return 4_u8 if (n_mod_100 >= 11)
|
||||
return 3_u8 if n_mod_100 >= 3 && n_mod_100 <= 10
|
||||
return 4_u8 if n_mod_100 >= 11
|
||||
5_u8
|
||||
end
|
||||
|
||||
@ -309,8 +309,8 @@ module I18next::Plurals
|
||||
# Rule: ((n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2)
|
||||
#
|
||||
def self.special_czech_slovak(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1)
|
||||
return 1_u8 if (count >= 2 && count <= 4)
|
||||
return 0_u8 if count == 1
|
||||
return 1_u8 if count >= 2 && count <= 4
|
||||
2_u8
|
||||
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)
|
||||
#
|
||||
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_100 = count % 100
|
||||
@ -338,9 +338,9 @@ module I18next::Plurals
|
||||
# Rule: ((n==1) ? 0 : (n==2) ? 1 : (n != 8 && n != 11) ? 2 : 3)
|
||||
#
|
||||
def self.special_welsh(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1)
|
||||
return 1_u8 if (count == 2)
|
||||
return 2_u8 if (count != 8 && count != 11)
|
||||
return 0_u8 if count == 1
|
||||
return 1_u8 if count == 2
|
||||
return 2_u8 if count != 8 && count != 11
|
||||
3_u8
|
||||
end
|
||||
|
||||
@ -350,10 +350,10 @@ module I18next::Plurals
|
||||
# Rule: (n==1 ? 0 : n==2 ? 1 : n<7 ? 2 : n<11 ? 3 : 4)
|
||||
#
|
||||
def self.special_irish(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1)
|
||||
return 1_u8 if (count == 2)
|
||||
return 2_u8 if (count < 7)
|
||||
return 3_u8 if (count < 11)
|
||||
return 0_u8 if count == 1
|
||||
return 1_u8 if count == 2
|
||||
return 2_u8 if count < 7
|
||||
return 3_u8 if count < 11
|
||||
4_u8
|
||||
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)
|
||||
#
|
||||
def self.special_scottish_gaelic(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1 || count == 11)
|
||||
return 1_u8 if (count == 2 || count == 12)
|
||||
return 2_u8 if (count > 2 && count < 20)
|
||||
return 0_u8 if count == 1 || count == 11
|
||||
return 1_u8 if count == 2 || count == 12
|
||||
return 2_u8 if count > 2 && count < 20
|
||||
3_u8
|
||||
end
|
||||
|
||||
@ -468,8 +468,8 @@ module I18next::Plurals
|
||||
return 1_u8 if count == 0
|
||||
|
||||
n_mod_100 = count % 100
|
||||
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 1_u8 if n_mod_100 > 1 && n_mod_100 < 11
|
||||
return 2_u8 if n_mod_100 > 10 && n_mod_100 < 20
|
||||
3_u8
|
||||
end
|
||||
|
||||
@ -483,7 +483,7 @@ module I18next::Plurals
|
||||
return 1_u8 if count == 0
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
@ -494,9 +494,9 @@ module I18next::Plurals
|
||||
#
|
||||
def self.special_slovenian(count : Int) : UInt8
|
||||
n_mod_100 = count % 100
|
||||
return 1_u8 if (n_mod_100 == 1)
|
||||
return 2_u8 if (n_mod_100 == 2)
|
||||
return 3_u8 if (n_mod_100 == 3 || n_mod_100 == 4)
|
||||
return 1_u8 if n_mod_100 == 1
|
||||
return 2_u8 if n_mod_100 == 2
|
||||
return 3_u8 if n_mod_100 == 3 || n_mod_100 == 4
|
||||
0_u8
|
||||
end
|
||||
|
||||
@ -506,8 +506,8 @@ module I18next::Plurals
|
||||
# Rule: (n==1 ? 0 : n==2 ? 1 : (n<0 || n>10) && n%10==0 ? 2 : 3)
|
||||
#
|
||||
def self.special_hebrew(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1)
|
||||
return 1_u8 if (count == 2)
|
||||
return 0_u8 if count == 1
|
||||
return 1_u8 if count == 2
|
||||
|
||||
if (count < 0 || count > 10) && (count % 10) == 0
|
||||
2_u8
|
||||
@ -535,8 +535,8 @@ module I18next::Plurals
|
||||
# This rule is mostly compliant to CLDR v42
|
||||
#
|
||||
def self.special_cldr_spanish_italian(count : Int) : UInt8
|
||||
return 0_u8 if (count == 1) # one
|
||||
return 1_u8 if (count != 0 && count % 1_000_000 == 0) # many
|
||||
return 0_u8 if count == 1 # one
|
||||
return 1_u8 if count != 0 && count % 1_000_000 == 0 # many
|
||||
2_u8 # other
|
||||
end
|
||||
|
||||
@ -545,8 +545,8 @@ module I18next::Plurals
|
||||
# This rule is mostly compliant to CLDR v42
|
||||
#
|
||||
def self.special_cldr_french_portuguese(count : Int) : UInt8
|
||||
return 0_u8 if (count == 0 || count == 1) # one
|
||||
return 1_u8 if (count % 1_000_000 == 0) # many
|
||||
return 0_u8 if count == 0 || count == 1 # one
|
||||
return 1_u8 if count % 1_000_000 == 0 # many
|
||||
2_u8 # other
|
||||
end
|
||||
|
||||
@ -558,8 +558,8 @@ module I18next::Plurals
|
||||
n_mod_10 = count % 10
|
||||
n_mod_100 = count % 100
|
||||
|
||||
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 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
|
||||
2_u8 # other
|
||||
end
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ module Invidious::Routes::API::V1::Misc
|
||||
{"software" => SOFTWARE}.to_json
|
||||
else
|
||||
# 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))
|
||||
|
||||
if !tracker.empty?
|
||||
|
||||
@ -35,7 +35,7 @@ def fetch_trending(trending_type, region, locale)
|
||||
# Ignore the smaller categories, as they generally contain a sponsored
|
||||
# channel, which brings a lot of noise on the trending page.
|
||||
# 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)
|
||||
else
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
best_m4a_stream_bitrate = 0
|
||||
audio_streams.each_with_index do |fmt, 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_index = i
|
||||
end
|
||||
@ -26,7 +26,7 @@
|
||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||
src_url += "&local=true" if params.local
|
||||
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"]
|
||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||
@ -42,7 +42,7 @@
|
||||
<% if params.quality == "dash"
|
||||
src_url = "/api/manifest/dash/id/" + video.id + "?local=true&unique_res=1"
|
||||
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">
|
||||
<% end %>
|
||||
@ -54,7 +54,7 @@
|
||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||
src_url += "&local=true" if params.local
|
||||
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"]
|
||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||
@ -70,7 +70,7 @@
|
||||
|
||||
<% preferred_captions.each do |caption|
|
||||
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}"
|
||||
%>
|
||||
<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|
|
||||
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}"
|
||||
%>
|
||||
<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
|
||||
|
||||
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
|
||||
# subscribers and `subscriberCountText` holds the handle, except when the
|
||||
|
||||
@ -78,7 +78,7 @@ module UrlSanitizer
|
||||
new_uri = URI.new(path: "/")
|
||||
|
||||
# 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
|
||||
.split('/', remove_empty: true)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user