mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 15:58:30 -06:00
Fix Style/VerboseNilType type of Ameba issues
This commit is contained in:
parent
3d6f266827
commit
db8e73760d
@ -107,7 +107,7 @@ class ChannelRedirect < Exception
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_batch_channels(channels)
|
def get_batch_channels(channels)
|
||||||
finished_channel = Channel(String | Nil).new
|
finished_channel = Channel(String?).new
|
||||||
max_threads = 10
|
max_threads = 10
|
||||||
|
|
||||||
spawn do
|
spawn do
|
||||||
|
|||||||
@ -139,7 +139,7 @@ def error_json_helper(
|
|||||||
env : HTTP::Server::Context,
|
env : HTTP::Server::Context,
|
||||||
status_code : Int32,
|
status_code : Int32,
|
||||||
exception : Exception,
|
exception : Exception,
|
||||||
additional_fields : Hash(String, Object) | Nil = nil,
|
additional_fields : Hash(String, Object)? = nil,
|
||||||
)
|
)
|
||||||
if exception.is_a?(InfoException)
|
if exception.is_a?(InfoException)
|
||||||
return error_json_helper(env, status_code, exception.message || "", additional_fields)
|
return error_json_helper(env, status_code, exception.message || "", additional_fields)
|
||||||
@ -161,7 +161,7 @@ def error_json_helper(
|
|||||||
env : HTTP::Server::Context,
|
env : HTTP::Server::Context,
|
||||||
status_code : Int32,
|
status_code : Int32,
|
||||||
message : String,
|
message : String,
|
||||||
additional_fields : Hash(String, Object) | Nil = nil,
|
additional_fields : Hash(String, Object)? = nil,
|
||||||
)
|
)
|
||||||
env.response.content_type = "application/json"
|
env.response.content_type = "application/json"
|
||||||
env.response.status_code = status_code
|
env.response.status_code = status_code
|
||||||
|
|||||||
@ -94,7 +94,7 @@ def load_all_locales
|
|||||||
return locales
|
return locales
|
||||||
end
|
end
|
||||||
|
|
||||||
def translate(locale : String?, key : String, text : String | Hash(String, String) | Nil = nil) : String
|
def translate(locale : String?, key : String, text : String | Hash(String, String)? = nil) : String
|
||||||
# Log a warning if "key" doesn't exist in en-US locale and return
|
# Log a warning if "key" doesn't exist in en-US locale and return
|
||||||
# that key as the text, so this is more or less transparent to the user.
|
# that key as the text, so this is more or less transparent to the user.
|
||||||
if !LOCALES["en-US"].has_key?(key)
|
if !LOCALES["en-US"].has_key?(key)
|
||||||
|
|||||||
@ -48,7 +48,7 @@ struct Video
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(json : JSON::Builder | Nil = nil)
|
def to_json(json : JSON::Builder? = nil)
|
||||||
to_json(nil, json)
|
to_json(nil, json)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -207,7 +207,7 @@ module YoutubeAPI
|
|||||||
|
|
||||||
# Region to provide to youtube, e.g to alter search results
|
# Region to provide to youtube, e.g to alter search results
|
||||||
# (this is passed as the `gl` parameter).
|
# (this is passed as the `gl` parameter).
|
||||||
property region : String | Nil
|
property region : String?
|
||||||
|
|
||||||
# Initialization function
|
# Initialization function
|
||||||
def initialize(
|
def initialize(
|
||||||
@ -283,7 +283,7 @@ module YoutubeAPI
|
|||||||
# Return, as a Hash, the "context" data required to request the
|
# Return, as a Hash, the "context" data required to request the
|
||||||
# youtube API endpoints.
|
# youtube API endpoints.
|
||||||
#
|
#
|
||||||
private def make_context(client_config : ClientConfig | Nil, video_id = "dQw4w9WgXcQ") : Hash
|
private def make_context(client_config : ClientConfig?, video_id = "dQw4w9WgXcQ") : Hash
|
||||||
# Use the default client config if nil is passed
|
# Use the default client config if nil is passed
|
||||||
client_config ||= DEFAULT_CLIENT_CONFIG
|
client_config ||= DEFAULT_CLIENT_CONFIG
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ module YoutubeAPI
|
|||||||
#
|
#
|
||||||
# - A playlist ID (parameters MUST be an empty string)
|
# - A playlist ID (parameters MUST be an empty string)
|
||||||
#
|
#
|
||||||
def browse(continuation : String, client_config : ClientConfig | Nil = nil)
|
def browse(continuation : String, client_config : ClientConfig? = nil)
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data = {
|
data = {
|
||||||
"context" => self.make_context(client_config),
|
"context" => self.make_context(client_config),
|
||||||
@ -368,7 +368,7 @@ module YoutubeAPI
|
|||||||
browse_id : String,
|
browse_id : String,
|
||||||
*, # Force the following parameters to be passed by name
|
*, # Force the following parameters to be passed by name
|
||||||
params : String,
|
params : String,
|
||||||
client_config : ClientConfig | Nil = nil,
|
client_config : ClientConfig? = nil,
|
||||||
)
|
)
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data = {
|
data = {
|
||||||
@ -421,7 +421,7 @@ module YoutubeAPI
|
|||||||
# })
|
# })
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
def next(continuation : String, *, client_config : ClientConfig | Nil = nil)
|
def next(continuation : String, *, client_config : ClientConfig? = nil)
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data = {
|
data = {
|
||||||
"context" => self.make_context(client_config),
|
"context" => self.make_context(client_config),
|
||||||
@ -432,7 +432,7 @@ module YoutubeAPI
|
|||||||
end
|
end
|
||||||
|
|
||||||
# :ditto:
|
# :ditto:
|
||||||
def next(data : Hash, *, client_config : ClientConfig | Nil = nil)
|
def next(data : Hash, *, client_config : ClientConfig? = nil)
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data2 = data.merge({
|
data2 = data.merge({
|
||||||
"context" => self.make_context(client_config),
|
"context" => self.make_context(client_config),
|
||||||
@ -442,7 +442,7 @@ module YoutubeAPI
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Allow a NamedTuple to be passed, too.
|
# Allow a NamedTuple to be passed, too.
|
||||||
def next(data : NamedTuple, *, client_config : ClientConfig | Nil = nil)
|
def next(data : NamedTuple, *, client_config : ClientConfig? = nil)
|
||||||
return self.next(data.to_h, client_config: client_config)
|
return self.next(data.to_h, client_config: client_config)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ module YoutubeAPI
|
|||||||
# channel_b = YoutubeAPI.resolve_url("https://youtube.com/c/invalid")
|
# channel_b = YoutubeAPI.resolve_url("https://youtube.com/c/invalid")
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
def resolve_url(url : String, client_config : ClientConfig | Nil = nil)
|
def resolve_url(url : String, client_config : ClientConfig? = nil)
|
||||||
data = {
|
data = {
|
||||||
"context" => self.make_context(nil),
|
"context" => self.make_context(nil),
|
||||||
"url" => url,
|
"url" => url,
|
||||||
@ -521,7 +521,7 @@ module YoutubeAPI
|
|||||||
def search(
|
def search(
|
||||||
search_query : String,
|
search_query : String,
|
||||||
params : String,
|
params : String,
|
||||||
client_config : ClientConfig | Nil = nil,
|
client_config : ClientConfig? = nil,
|
||||||
)
|
)
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data = {
|
data = {
|
||||||
@ -547,7 +547,7 @@ module YoutubeAPI
|
|||||||
|
|
||||||
def get_transcript(
|
def get_transcript(
|
||||||
params : String,
|
params : String,
|
||||||
client_config : ClientConfig | Nil = nil,
|
client_config : ClientConfig? = nil,
|
||||||
) : Hash(String, JSON::Any)
|
) : Hash(String, JSON::Any)
|
||||||
data = {
|
data = {
|
||||||
"context" => self.make_context(client_config),
|
"context" => self.make_context(client_config),
|
||||||
@ -569,7 +569,7 @@ module YoutubeAPI
|
|||||||
def _post_json(
|
def _post_json(
|
||||||
endpoint : String,
|
endpoint : String,
|
||||||
data : Hash,
|
data : Hash,
|
||||||
client_config : ClientConfig | Nil,
|
client_config : ClientConfig?,
|
||||||
) : Hash(String, JSON::Any)
|
) : Hash(String, JSON::Any)
|
||||||
# Use the default client config if nil is passed
|
# Use the default client config if nil is passed
|
||||||
client_config ||= DEFAULT_CLIENT_CONFIG
|
client_config ||= DEFAULT_CLIENT_CONFIG
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user