diff --git a/src/invidious/comments/content.cr b/src/invidious/comments/content.cr
index beefd9ad..3e0d41d7 100644
--- a/src/invidious/comments/content.cr
+++ b/src/invidious/comments/content.cr
@@ -5,35 +5,35 @@ def text_to_parsed_content(text : String) : JSON::Any
# In first case line is just a simple node before
# check patterns inside line
# { 'text': line }
- currentNodes = [] of JSON::Any
- initialNode = {"text" => line}
- currentNodes << (JSON.parse(initialNode.to_json))
+ current_nodes = [] of JSON::Any
+ initial_node = {"text" => line}
+ current_nodes << (JSON.parse(initial_node.to_json))
# For each match with url pattern, get last node and preserve
# last node before create new node with url information
# { 'text': match, 'navigationEndpoint': { 'urlEndpoint' : 'url': match } }
- line.scan(/https?:\/\/[^ ]*/).each do |urlMatch|
+ line.scan(/https?:\/\/[^ ]*/).each do |url_match|
# Retrieve last node and update node without match
- lastNode = currentNodes[currentNodes.size - 1].as_h
- splittedLastNode = lastNode["text"].as_s.split(urlMatch[0])
- lastNode["text"] = JSON.parse(splittedLastNode[0].to_json)
- currentNodes[currentNodes.size - 1] = JSON.parse(lastNode.to_json)
+ last_node = current_nodes[current_nodes.size - 1].as_h
+ splitted_last_node = last_node["text"].as_s.split(url_match[0])
+ last_node["text"] = JSON.parse(splitted_last_node[0].to_json)
+ current_nodes[current_nodes.size - 1] = JSON.parse(last_node.to_json)
# Create new node with match and navigation infos
- currentNode = {"text" => urlMatch[0], "navigationEndpoint" => {"urlEndpoint" => {"url" => urlMatch[0]}}}
- currentNodes << (JSON.parse(currentNode.to_json))
+ current_node = {"text" => url_match[0], "navigationEndpoint" => {"urlEndpoint" => {"url" => url_match[0]}}}
+ current_nodes << (JSON.parse(current_node.to_json))
# If text remain after match create new simple node with text after match
- afterNode = {"text" => splittedLastNode.size > 1 ? splittedLastNode[1] : ""}
- currentNodes << (JSON.parse(afterNode.to_json))
+ after_node = {"text" => splitted_last_node.size > 1 ? splitted_last_node[1] : ""}
+ current_nodes << (JSON.parse(after_node.to_json))
end
# After processing of matches inside line
# Add \n at end of last node for preserve carriage return
- lastNode = currentNodes[currentNodes.size - 1].as_h
- lastNode["text"] = JSON.parse("#{currentNodes[currentNodes.size - 1]["text"]}\n".to_json)
- currentNodes[currentNodes.size - 1] = JSON.parse(lastNode.to_json)
+ last_node = current_nodes[current_nodes.size - 1].as_h
+ last_node["text"] = JSON.parse("#{current_nodes[current_nodes.size - 1]["text"]}\n".to_json)
+ current_nodes[current_nodes.size - 1] = JSON.parse(last_node.to_json)
# Finally add final nodes to nodes returned
- currentNodes.each do |node|
+ current_nodes.each do |node|
nodes << (node)
end
end
@@ -53,8 +53,8 @@ def content_to_comment_html(content, video_id : String? = "")
text = HTML.escape(run["text"].as_s)
- if navigationEndpoint = run.dig?("navigationEndpoint")
- text = parse_link_endpoint(navigationEndpoint, text, video_id)
+ if navigation_endpoint = run.dig?("navigationEndpoint")
+ text = parse_link_endpoint(navigation_endpoint, text, video_id)
end
text = "#{text}" if run["bold"]?
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index e438e3b9..8e9e9a6a 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -52,9 +52,9 @@ def recode_length_seconds(time)
end
def decode_interval(string : String) : Time::Span
- rawMinutes = string.try &.to_i32?
+ raw_minutes = string.try &.to_i32?
- if !rawMinutes
+ if !raw_minutes
hours = /(?\d+)h/.match(string).try &.["hours"].try &.to_i32
hours ||= 0
@@ -63,7 +63,7 @@ def decode_interval(string : String) : Time::Span
time = Time::Span.new(hours: hours, minutes: minutes)
else
- time = Time::Span.new(minutes: rawMinutes)
+ time = Time::Span.new(minutes: raw_minutes)
end
return time
diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr
index 12942906..52a985b1 100644
--- a/src/invidious/routes/api/v1/misc.cr
+++ b/src/invidious/routes/api/v1/misc.cr
@@ -177,8 +177,8 @@ module Invidious::Routes::API::V1::Misc
begin
resolved_url = YoutubeAPI.resolve_url(url.as(String))
endpoint = resolved_url["endpoint"]
- pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
- if pageType == "WEB_PAGE_TYPE_UNKNOWN"
+ page_type = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
+ if page_type == "WEB_PAGE_TYPE_UNKNOWN"
return error_json(400, "Unknown url")
end
@@ -194,7 +194,7 @@ module Invidious::Routes::API::V1::Misc
json.field "playlistId", sub_endpoint["playlistId"].as_s if sub_endpoint["playlistId"]?
json.field "startTimeSeconds", sub_endpoint["startTimeSeconds"].as_i if sub_endpoint["startTimeSeconds"]?
json.field "params", params.try &.as_s
- json.field "pageType", pageType
+ json.field "pageType", page_type
end
end
end