Fix Style/RedundantSelf type of Ameba issues

This commit is contained in:
Sijawusz Pur Rahnama 2026-01-11 22:34:23 +01:00
parent db8e73760d
commit d371829477
18 changed files with 214 additions and 214 deletions

View File

@ -26,21 +26,21 @@ struct ChannelVideo
json.object do
json.field "type", "shortVideo"
json.field "title", self.title
json.field "videoId", self.id
json.field "title", title
json.field "videoId", id
json.field "videoThumbnails" do
Invidious::JSONify::APIv1.thumbnails(json, self.id)
Invidious::JSONify::APIv1.thumbnails(json, id)
end
json.field "lengthSeconds", self.length_seconds
json.field "lengthSeconds", length_seconds
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "published", self.published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(self.published, locale))
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", "/channel/#{ucid}"
json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
json.field "viewCount", self.views
json.field "viewCount", views
end
end
@ -51,34 +51,34 @@ struct ChannelVideo
end
def to_xml(locale, query_params, xml : XML::Builder)
query_params["v"] = self.id
query_params["v"] = id
xml.element("entry") do
xml.element("id") { xml.text "yt:video:#{self.id}" }
xml.element("yt:videoId") { xml.text self.id }
xml.element("yt:channelId") { xml.text self.ucid }
xml.element("title") { xml.text self.title }
xml.element("id") { xml.text "yt:video:#{id}" }
xml.element("yt:videoId") { xml.text id }
xml.element("yt:channelId") { xml.text ucid }
xml.element("title") { xml.text title }
xml.element("link", rel: "alternate", href: "#{HOST_URL}/watch?#{query_params}")
xml.element("author") do
xml.element("name") { xml.text self.author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{self.ucid}" }
xml.element("name") { xml.text author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{ucid}" }
end
xml.element("content", type: "xhtml") do
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
xml.element("a", href: "#{HOST_URL}/watch?#{query_params}") do
xml.element("img", src: "#{HOST_URL}/vi/#{self.id}/mqdefault.jpg")
xml.element("img", src: "#{HOST_URL}/vi/#{id}/mqdefault.jpg")
end
end
end
xml.element("published") { xml.text self.published.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("updated") { xml.text self.updated.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("published") { xml.text published.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("updated") { xml.text updated.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("media:group") do
xml.element("media:title") { xml.text self.title }
xml.element("media:thumbnail", url: "#{HOST_URL}/vi/#{self.id}/mqdefault.jpg",
xml.element("media:title") { xml.text title }
xml.element("media:thumbnail", url: "#{HOST_URL}/vi/#{id}/mqdefault.jpg",
width: "320", height: "180")
end
end

View File

@ -11,7 +11,7 @@ module Invidious::Frontend::Comments
replies_html = ""
if child.replies.is_a?(RedditThing)
replies = child.replies.as(RedditThing)
replies_html = self.template_reddit(replies.data.as(RedditListing).children, locale)
replies_html = template_reddit(replies.data.as(RedditListing).children, locale)
end
if child.depth > 0

View File

@ -70,7 +70,7 @@ module Invidious::Frontend::Pagination
params_prev = URI::Params{"page" => (current_page - 1).to_s}
url_prev = HttpServer::Utils.add_params_to_url(base_url, params_prev)
self.previous_page(str, locale, url_prev.to_s)
previous_page(str, locale, url_prev.to_s)
end
str << %(</div>\n)
@ -80,7 +80,7 @@ module Invidious::Frontend::Pagination
params_next = URI::Params{"page" => (current_page + 1).to_s}
url_next = HttpServer::Utils.add_params_to_url(base_url, params_next)
self.next_page(str, locale, url_next.to_s)
next_page(str, locale, url_next.to_s)
end
str << %(</div>\n)
@ -109,7 +109,7 @@ module Invidious::Frontend::Pagination
params["continuation"] = ctoken
url_next = HttpServer::Utils.add_params_to_url(base_url, params)
self.next_page(str, locale, url_next.to_s)
next_page(str, locale, url_next.to_s)
end
str << %(</div>\n)

View File

@ -151,17 +151,17 @@ module I18next::Plurals
@version = version.to_u8
end
self.init_rules
init_rules
end
def init_rules
# Look into sets
PLURAL_SETS.each do |form, langs|
langs.each { |lang| self.forms[lang] = form }
langs.each { |lang| forms[lang] = form }
end
# Add plurals from the "singles" set
self.forms.merge!(PLURAL_SINGLES)
forms.merge!(PLURAL_SINGLES)
end
def get_plural_form(locale : String) : PluralForms
@ -170,7 +170,7 @@ module I18next::Plurals
locale = locale.split('-')[0]
end
return self.forms[locale] if self.forms[locale]?
return forms[locale] if forms[locale]?
# If nothing was found, then use the most common form, i.e
# one singular and one plural, as in english. Not perfect,

View File

@ -28,19 +28,19 @@ struct SearchVideo
property badges : VideoBadges
def to_xml(auto_generated, query_params, xml : XML::Builder)
query_params["v"] = self.id
query_params["v"] = id
xml.element("entry") do
xml.element("id") { xml.text "yt:video:#{self.id}" }
xml.element("yt:videoId") { xml.text self.id }
xml.element("yt:channelId") { xml.text self.ucid }
xml.element("title") { xml.text self.title }
xml.element("id") { xml.text "yt:video:#{id}" }
xml.element("yt:videoId") { xml.text id }
xml.element("yt:channelId") { xml.text ucid }
xml.element("title") { xml.text title }
xml.element("link", rel: "alternate", href: "#{HOST_URL}/watch?#{query_params}")
xml.element("author") do
if auto_generated
xml.element("name") { xml.text self.author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{self.ucid}" }
xml.element("name") { xml.text author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{ucid}" }
else
xml.element("name") { xml.text author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{ucid}" }
@ -50,24 +50,24 @@ struct SearchVideo
xml.element("content", type: "xhtml") do
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
xml.element("a", href: "#{HOST_URL}/watch?#{query_params}") do
xml.element("img", src: "#{HOST_URL}/vi/#{self.id}/mqdefault.jpg")
xml.element("img", src: "#{HOST_URL}/vi/#{id}/mqdefault.jpg")
end
xml.element("p", style: "word-break:break-word;white-space:pre-wrap") { xml.text html_to_content(self.description_html) }
xml.element("p", style: "word-break:break-word;white-space:pre-wrap") { xml.text html_to_content(description_html) }
end
end
xml.element("published") { xml.text self.published.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("published") { xml.text published.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("media:group") do
xml.element("media:title") { xml.text self.title }
xml.element("media:thumbnail", url: "#{HOST_URL}/vi/#{self.id}/mqdefault.jpg",
xml.element("media:title") { xml.text title }
xml.element("media:thumbnail", url: "#{HOST_URL}/vi/#{id}/mqdefault.jpg",
width: "320", height: "180")
xml.element("media:description") { xml.text html_to_content(self.description_html) }
xml.element("media:description") { xml.text html_to_content(description_html) }
end
xml.element("media:community") do
xml.element("media:statistics", views: self.views)
xml.element("media:statistics", views: views)
end
end
end
@ -81,13 +81,13 @@ struct SearchVideo
def to_json(locale : String?, json : JSON::Builder)
json.object do
json.field "type", "video"
json.field "title", self.title
json.field "videoId", self.id
json.field "title", title
json.field "videoId", id
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "authorVerified", self.author_verified
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", "/channel/#{ucid}"
json.field "authorVerified", author_verified
author_thumbnail = self.author_thumbnail
@ -108,31 +108,31 @@ struct SearchVideo
end
json.field "videoThumbnails" do
Invidious::JSONify::APIv1.thumbnails(json, self.id)
Invidious::JSONify::APIv1.thumbnails(json, id)
end
json.field "description", html_to_content(self.description_html)
json.field "descriptionHtml", self.description_html
json.field "description", html_to_content(description_html)
json.field "descriptionHtml", description_html
json.field "viewCount", self.views
json.field "viewCountText", translate_count(locale, "generic_views_count", self.views, NumberFormatting::Short)
json.field "published", self.published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(self.published, locale))
json.field "lengthSeconds", self.length_seconds
json.field "liveNow", self.badges.live_now?
json.field "premium", self.badges.premium?
json.field "isUpcoming", self.upcoming?
json.field "viewCount", views
json.field "viewCountText", translate_count(locale, "generic_views_count", views, NumberFormatting::Short)
json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
json.field "lengthSeconds", length_seconds
json.field "liveNow", badges.live_now?
json.field "premium", badges.premium?
json.field "isUpcoming", upcoming?
if self.premiere_timestamp
json.field "premiereTimestamp", self.premiere_timestamp.try &.to_unix
if premiere_timestamp
json.field "premiereTimestamp", premiere_timestamp.try &.to_unix
end
json.field "isNew", self.badges.new?
json.field "is4k", self.badges.four_k?
json.field "is8k", self.badges.eight_k?
json.field "isVr180", self.badges.vr180?
json.field "isVr360", self.badges.vr360?
json.field "is3d", self.badges.three_d?
json.field "hasCaptions", self.badges.closed_captions?
json.field "isNew", badges.new?
json.field "is4k", badges.four_k?
json.field "is8k", badges.eight_k?
json.field "isVr180", badges.vr180?
json.field "isVr360", badges.vr360?
json.field "is3d", badges.three_d?
json.field "hasCaptions", badges.closed_captions?
end
end
@ -175,20 +175,20 @@ struct SearchPlaylist
def to_json(locale : String?, json : JSON::Builder)
json.object do
json.field "type", "playlist"
json.field "title", self.title
json.field "playlistId", self.id
json.field "playlistThumbnail", self.thumbnail
json.field "title", title
json.field "playlistId", id
json.field "playlistThumbnail", thumbnail
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", "/channel/#{ucid}"
json.field "authorVerified", self.author_verified
json.field "authorVerified", author_verified
json.field "videoCount", self.video_count
json.field "videoCount", video_count
json.field "videos" do
json.array do
self.videos.each do |video|
videos.each do |video|
json.object do
json.field "title", video.title
json.field "videoId", video.id
@ -232,17 +232,17 @@ struct SearchChannel
def to_json(locale : String?, json : JSON::Builder)
json.object do
json.field "type", "channel"
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "authorVerified", self.author_verified
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", "/channel/#{ucid}"
json.field "authorVerified", author_verified
json.field "authorThumbnails" do
json.array do
qualities = {32, 48, 76, 100, 176, 512}
qualities.each do |quality|
json.object do
json.field "url", self.author_thumbnail.gsub(/=s\d+/, "=s#{quality}")
json.field "url", author_thumbnail.gsub(/=s\d+/, "=s#{quality}")
json.field "width", quality
json.field "height", quality
end
@ -250,13 +250,13 @@ struct SearchChannel
end
end
json.field "autoGenerated", self.auto_generated
json.field "subCount", self.subscriber_count
json.field "videoCount", self.video_count
json.field "channelHandle", self.channel_handle
json.field "autoGenerated", auto_generated
json.field "subCount", subscriber_count
json.field "videoCount", video_count
json.field "channelHandle", channel_handle
json.field "description", html_to_content(self.description_html)
json.field "descriptionHtml", self.description_html
json.field "description", html_to_content(description_html)
json.field "descriptionHtml", description_html
end
end
@ -283,10 +283,10 @@ struct SearchHashtag
def to_json(locale : String?, json : JSON::Builder)
json.object do
json.field "type", "hashtag"
json.field "title", self.title
json.field "url", self.url
json.field "videoCount", self.video_count
json.field "channelCount", self.channel_count
json.field "title", title
json.field "url", url
json.field "videoCount", video_count
json.field "channelCount", channel_count
end
end
end
@ -352,10 +352,10 @@ class Category
def to_json(locale : String?, json : JSON::Builder)
json.object do
json.field "type", "category"
json.field "title", self.title
json.field "title", title
json.field "contents" do
json.array do
self.contents.each do |item|
contents.each do |item|
item.to_json(locale, json)
end
end

View File

@ -20,7 +20,7 @@ module WebVTT
# Writes an vtt cue with the specified time stamp and contents
def cue(start_time : Time::Span, end_time : Time::Span, text : String)
timestamp(start_time, end_time)
@io << self.escape(text)
@io << escape(text)
@io << "\n\n"
end

View File

@ -25,7 +25,7 @@ class Invidious::Jobs::InstanceListRefreshJob < Invidious::Jobs::BaseJob
# - Is it an instance with a good uptime?
# - Is it an updated instance?
private def refresh_instances
raw_instance_list = self.fetch_instances
raw_instance_list = fetch_instances
filtered_instance_list = [] of Tuple(String, String)
raw_instance_list.each do |instance_data|

View File

@ -13,10 +13,10 @@ module Invidious::JSONify::APIv1
json.field "error", video.info["reason"] if video.info["reason"]?
json.field "videoThumbnails" do
self.thumbnails(json, video.id)
thumbnails(json, video.id)
end
json.field "storyboards" do
self.storyboards(json, video.id, video.storyboards)
storyboards(json, video.id, video.storyboards)
end
json.field "description", video.description
@ -241,7 +241,7 @@ module Invidious::JSONify::APIv1
json.field "videoId", rv["id"]
json.field "title", rv["title"]
json.field "videoThumbnails" do
self.thumbnails(json, rv["id"])
thumbnails(json, rv["id"])
end
json.field "author", rv["author"]

View File

@ -13,30 +13,30 @@ struct PlaylistVideo
def to_xml(xml : XML::Builder)
xml.element("entry") do
xml.element("id") { xml.text "yt:video:#{self.id}" }
xml.element("yt:videoId") { xml.text self.id }
xml.element("yt:channelId") { xml.text self.ucid }
xml.element("title") { xml.text self.title }
xml.element("link", rel: "alternate", href: "#{HOST_URL}/watch?v=#{self.id}")
xml.element("id") { xml.text "yt:video:#{id}" }
xml.element("yt:videoId") { xml.text id }
xml.element("yt:channelId") { xml.text ucid }
xml.element("title") { xml.text title }
xml.element("link", rel: "alternate", href: "#{HOST_URL}/watch?v=#{id}")
xml.element("author") do
xml.element("name") { xml.text self.author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{self.ucid}" }
xml.element("name") { xml.text author }
xml.element("uri") { xml.text "#{HOST_URL}/channel/#{ucid}" }
end
xml.element("content", type: "xhtml") do
xml.element("div", xmlns: "http://www.w3.org/1999/xhtml") do
xml.element("a", href: "#{HOST_URL}/watch?v=#{self.id}") do
xml.element("img", src: "#{HOST_URL}/vi/#{self.id}/mqdefault.jpg")
xml.element("a", href: "#{HOST_URL}/watch?v=#{id}") do
xml.element("img", src: "#{HOST_URL}/vi/#{id}/mqdefault.jpg")
end
end
end
xml.element("published") { xml.text self.published.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("published") { xml.text published.to_s("%Y-%m-%dT%H:%M:%S%:z") }
xml.element("media:group") do
xml.element("media:title") { xml.text self.title }
xml.element("media:thumbnail", url: "#{HOST_URL}/vi/#{self.id}/mqdefault.jpg",
xml.element("media:title") { xml.text title }
xml.element("media:thumbnail", url: "#{HOST_URL}/vi/#{id}/mqdefault.jpg",
width: "320", height: "180")
end
end
@ -54,15 +54,15 @@ struct PlaylistVideo
json.object do
json.field "type", "video"
json.field "title", self.title
json.field "videoId", self.id
json.field "title", title
json.field "videoId", id
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", "/channel/#{ucid}"
json.field "videoThumbnails" do
Invidious::JSONify::APIv1.thumbnails(json, self.id)
Invidious::JSONify::APIv1.thumbnails(json, id)
end
if index
@ -72,8 +72,8 @@ struct PlaylistVideo
json.field "index", self.index
end
json.field "lengthSeconds", self.length_seconds
json.field "liveNow", self.live_now
json.field "lengthSeconds", length_seconds
json.field "liveNow", live_now
end
end
@ -101,14 +101,14 @@ struct Playlist
def to_json(offset, json : JSON::Builder, video_id : String? = nil)
json.object do
json.field "type", "playlist"
json.field "title", self.title
json.field "playlistId", self.id
json.field "playlistThumbnail", self.thumbnail
json.field "title", title
json.field "playlistId", id
json.field "playlistThumbnail", thumbnail
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
json.field "subtitle", self.subtitle
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", "/channel/#{ucid}"
json.field "subtitle", subtitle
json.field "authorThumbnails" do
json.array do
@ -116,7 +116,7 @@ struct Playlist
qualities.each do |quality|
json.object do
json.field "url", self.author_thumbnail.not_nil!.gsub(/=\d+/, "=s#{quality}")
json.field "url", author_thumbnail.not_nil!.gsub(/=\d+/, "=s#{quality}")
json.field "width", quality
json.field "height", quality
end
@ -124,13 +124,13 @@ struct Playlist
end
end
json.field "description", self.description
json.field "descriptionHtml", self.description_html
json.field "videoCount", self.video_count
json.field "description", description
json.field "descriptionHtml", description_html
json.field "videoCount", video_count
json.field "viewCount", self.views
json.field "updated", self.updated.to_unix
json.field "isListed", self.privacy.public?
json.field "viewCount", views
json.field "updated", updated.to_unix
json.field "isListed", privacy.public?
json.field "videos" do
json.array do
@ -187,26 +187,26 @@ struct InvidiousPlaylist
def to_json(offset, json : JSON::Builder, video_id : String? = nil)
json.object do
json.field "type", "invidiousPlaylist"
json.field "title", self.title
json.field "playlistId", self.id
json.field "title", title
json.field "playlistId", id
json.field "author", self.author
json.field "authorId", self.ucid
json.field "author", author
json.field "authorId", ucid
json.field "authorUrl", nil
json.field "authorThumbnails", [] of String
json.field "description", html_to_content(self.description_html)
json.field "descriptionHtml", self.description_html
json.field "videoCount", self.video_count
json.field "description", html_to_content(description_html)
json.field "descriptionHtml", description_html
json.field "videoCount", video_count
json.field "viewCount", self.views
json.field "updated", self.updated.to_unix
json.field "isListed", self.privacy.public?
json.field "viewCount", views
json.field "updated", updated.to_unix
json.field "isListed", privacy.public?
json.field "videos" do
json.array do
if (!offset || offset == 0) && !video_id.nil?
index = Invidious::Database::PlaylistVideos.select_index(self.id, video_id)
index = Invidious::Database::PlaylistVideos.select_index(id, video_id)
offset = self.index.index(index) || 0
end
@ -227,7 +227,7 @@ struct InvidiousPlaylist
def thumbnail
# TODO: Get playlist thumbnail from playlist data rather than first video
@thumbnail_id ||= Invidious::Database::PlaylistVideos.select_one_id(self.id, self.index) || "-----------"
@thumbnail_id ||= Invidious::Database::PlaylistVideos.select_one_id(id, index) || "-----------"
"/vi/#{@thumbnail_id}/mqdefault.jpg"
end
@ -244,7 +244,7 @@ struct InvidiousPlaylist
end
def description_html
HTML.escape(self.description)
HTML.escape(description)
end
end

View File

@ -137,7 +137,7 @@ module Invidious::Routes::API::V1::Channels
env.params.query.delete("sort_by") if env.params.query.has_key?("sort_by")
env.params.query.delete("continuation") if env.params.query.has_key?("continuation")
return self.videos(env)
return videos(env)
end
def self.videos(env)

View File

@ -8,11 +8,11 @@ module Invidious::Routes::Channels
end
def self.home(env)
self.videos(env)
videos(env)
end
def self.videos(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -64,7 +64,7 @@ module Invidious::Routes::Channels
end
def self.shorts(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -99,7 +99,7 @@ module Invidious::Routes::Channels
end
def self.streams(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -134,7 +134,7 @@ module Invidious::Routes::Channels
end
def self.playlists(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -158,7 +158,7 @@ module Invidious::Routes::Channels
end
def self.podcasts(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -178,7 +178,7 @@ module Invidious::Routes::Channels
end
def self.releases(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -198,7 +198,7 @@ module Invidious::Routes::Channels
end
def self.courses(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -220,7 +220,7 @@ module Invidious::Routes::Channels
def self.community(env)
return env.redirect env.request.path.sub("posts", "community") if env.request.path.split("/").last == "posts"
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
if !data.is_a?(Tuple)
return data
end
@ -298,7 +298,7 @@ module Invidious::Routes::Channels
end
def self.channels(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
return data if !data.is_a?(Tuple)
locale, user, subscriptions, continuation, ucid, channel = data
@ -318,7 +318,7 @@ module Invidious::Routes::Channels
end
def self.about(env)
data = self.fetch_basic_information(env)
data = fetch_basic_information(env)
if !data.is_a?(Tuple)
return data
end

View File

@ -9,7 +9,7 @@ module Invidious::Routes::Companion
begin
COMPANION_POOL.client do |wrapper|
wrapper.client.get(url, env.request.headers) do |resp|
return self.proxy_companion(env, resp)
return proxy_companion(env, resp)
end
end
rescue ex
@ -26,7 +26,7 @@ module Invidious::Routes::Companion
begin
COMPANION_POOL.client do |wrapper|
wrapper.client.post(url, env.request.headers, env.request.body) do |resp|
return self.proxy_companion(env, resp)
return proxy_companion(env, resp)
end
end
rescue ex
@ -42,7 +42,7 @@ module Invidious::Routes::Companion
begin
COMPANION_POOL.client do |wrapper|
wrapper.client.options(url, env.request.headers) do |resp|
return self.proxy_companion(env, resp)
return proxy_companion(env, resp)
end
end
rescue ex

View File

@ -13,7 +13,7 @@ module Invidious::Routes::Images
begin
GGPHT_POOL.client &.get(url, headers) do |resp|
return self.proxy_image(env, resp)
return proxy_image(env, resp)
end
rescue ex
end
@ -44,7 +44,7 @@ module Invidious::Routes::Images
begin
get_ytimg_pool(authority).client &.get(url, headers) do |resp|
env.response.headers["Connection"] = "close"
return self.proxy_image(env, resp)
return proxy_image(env, resp)
end
rescue ex
end
@ -66,7 +66,7 @@ module Invidious::Routes::Images
begin
get_ytimg_pool("i9").client &.get(url, headers) do |resp|
return self.proxy_image(env, resp)
return proxy_image(env, resp)
end
rescue ex
end
@ -128,7 +128,7 @@ module Invidious::Routes::Images
begin
get_ytimg_pool("i").client &.get(url, headers) do |resp|
return self.proxy_image(env, resp)
return proxy_image(env, resp)
end
rescue ex
end

View File

@ -42,11 +42,11 @@ module Invidious::Routing
end
{% end %}
self.register_image_routes
self.register_api_v1_routes
self.register_api_manifest_routes
self.register_video_playback_routes
self.register_companion_routes
register_image_routes
register_api_v1_routes
register_api_manifest_routes
register_video_playback_routes
register_companion_routes
end
# -------------------

View File

@ -30,7 +30,7 @@ module Invidious::Search
# Same as `empty_raw_query?`, but named for external use
def empty?
return self.empty_raw_query?
return empty_raw_query?
end
# Getter for the query string.
@ -70,7 +70,7 @@ module Invidious::Search
# Stop here if raw query is empty
# NOTE: maybe raise in the future?
return if self.empty_raw_query?
return if empty_raw_query?
# Specific handling
case @type
@ -120,7 +120,7 @@ module Invidious::Search
items = [] of SearchItem
# Don't bother going further if search query is empty
return items if self.empty_raw_query?
return items if empty_raw_query?
case @type
when .regular?, .playlist?

View File

@ -73,7 +73,7 @@ struct Video
end
def live_now
return (self.video_type == VideoType::Livestream)
return (video_type == VideoType::Livestream)
end
def post_live_dvr
@ -124,11 +124,11 @@ struct Video
def storyboards
container = info.dig?("storyboards") || JSON::Any.new("{}")
return IV::Videos::Storyboard.from_yt_json(container, self.length_seconds)
return IV::Videos::Storyboard.from_yt_json(container, length_seconds)
end
def paid
return (self.reason || "").includes? "requires payment"
return (reason || "").includes? "requires payment"
end
def premium
@ -170,7 +170,7 @@ struct Video
end
def vr? : Bool?
return {"EQUIRECTANGULAR", "MESH"}.includes? self.projection_type
return {"EQUIRECTANGULAR", "MESH"}.includes? projection_type
end
def projection_type : String?

View File

@ -64,7 +64,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = (item["videoRenderer"]? || item["gridVideoRenderer"]?)
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -192,7 +192,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = (item["channelRenderer"]? || item["gridChannelRenderer"]?)
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -255,7 +255,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["hashtagTileRenderer"]?
return self.parse(item_contents)
return parse(item_contents)
end
end
@ -308,7 +308,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["gridPlaylistRenderer"]?
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -352,7 +352,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["playlistRenderer"]?
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -415,7 +415,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["shelfRenderer"]?
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -484,7 +484,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item.dig?("itemSectionRenderer", "contents", 0)
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -513,7 +513,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item.dig?("richItemRenderer", "content")
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -546,7 +546,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["reelItemRenderer"]?
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -643,7 +643,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["lockupViewModel"]?
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -721,7 +721,7 @@ private module Parsers
def process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["shortsLockupViewModel"]?
return self.parse(item_contents, author_fallback)
return parse(item_contents, author_fallback)
end
end
@ -778,7 +778,7 @@ private module Parsers
module ContinuationItemRendererParser
def self.process(item : JSON::Any, author_fallback : AuthorFallback)
if item_contents = item["continuationItemRenderer"]?
return self.parse(item_contents)
return parse(item_contents)
end
end
@ -831,7 +831,7 @@ private module Extractors
module YouTubeTabs
def self.process(initial_data : InitialData)
if target = initial_data["twoColumnBrowseResultsRenderer"]?
self.extract(target)
extract(target)
end
end
@ -853,7 +853,7 @@ private module Extractors
contents.as_a.each do |item|
if item_section_content = item.dig?("itemSectionRenderer", "contents")
raw_items += self.unpack_item_section(item_section_content)
raw_items += unpack_item_section(item_section_content)
else
raw_items << item
end
@ -902,7 +902,7 @@ private module Extractors
module SearchResults
def self.process(initial_data : InitialData)
if target = initial_data["twoColumnSearchResultsRenderer"]?
self.extract(target)
extract(target)
end
end
@ -936,11 +936,11 @@ private module Extractors
module ContinuationContent
def self.process(initial_data : InitialData)
if target = initial_data["continuationContents"]?
self.extract(target)
extract(target)
elsif target = initial_data["appendContinuationItemsAction"]?
self.extract(target)
extract(target)
elsif target = initial_data["reloadContinuationItemsCommand"]?
self.extract(target)
extract(target)
end
end

View File

@ -268,7 +268,7 @@ module YoutubeAPI
# Convert to string, for logging purposes
def to_s
return {
client_type: self.name,
client_type: name,
region: @region,
}.to_s
end
@ -356,11 +356,11 @@ module YoutubeAPI
def browse(continuation : String, client_config : ClientConfig? = nil)
# JSON Request data, required by the API
data = {
"context" => self.make_context(client_config),
"context" => make_context(client_config),
"continuation" => continuation,
}
return self._post_json("/youtubei/v1/browse", data, client_config)
return _post_json("/youtubei/v1/browse", data, client_config)
end
# :ditto:
@ -373,7 +373,7 @@ module YoutubeAPI
# JSON Request data, required by the API
data = {
"browseId" => browse_id,
"context" => self.make_context(client_config),
"context" => make_context(client_config),
}
# Append the additional parameters if those were provided
@ -382,7 +382,7 @@ module YoutubeAPI
data["params"] = params
end
return self._post_json("/youtubei/v1/browse", data, client_config)
return _post_json("/youtubei/v1/browse", data, client_config)
end
####################################################################
@ -424,21 +424,21 @@ module YoutubeAPI
def next(continuation : String, *, client_config : ClientConfig? = nil)
# JSON Request data, required by the API
data = {
"context" => self.make_context(client_config),
"context" => make_context(client_config),
"continuation" => continuation,
}
return self._post_json("/youtubei/v1/next", data, client_config)
return _post_json("/youtubei/v1/next", data, client_config)
end
# :ditto:
def next(data : Hash, *, client_config : ClientConfig? = nil)
# JSON Request data, required by the API
data2 = data.merge({
"context" => self.make_context(client_config),
"context" => make_context(client_config),
})
return self._post_json("/youtubei/v1/next", data2, client_config)
return _post_json("/youtubei/v1/next", data2, client_config)
end
# Allow a NamedTuple to be passed, too.
@ -461,7 +461,7 @@ module YoutubeAPI
}
if CONFIG.invidious_companion.present?
return self._post_invidious_companion("/youtubei/v1/player", data)
return _post_invidious_companion("/youtubei/v1/player", data)
else
return nil
end
@ -497,11 +497,11 @@ module YoutubeAPI
#
def resolve_url(url : String, client_config : ClientConfig? = nil)
data = {
"context" => self.make_context(nil),
"context" => make_context(nil),
"url" => url,
}
return self._post_json("/youtubei/v1/navigation/resolve_url", data, client_config)
return _post_json("/youtubei/v1/navigation/resolve_url", data, client_config)
end
####################################################################
@ -526,11 +526,11 @@ module YoutubeAPI
# JSON Request data, required by the API
data = {
"query" => search_query,
"context" => self.make_context(client_config),
"context" => make_context(client_config),
"params" => params,
}
return self._post_json("/youtubei/v1/search", data, client_config)
return _post_json("/youtubei/v1/search", data, client_config)
end
####################################################################
@ -550,11 +550,11 @@ module YoutubeAPI
client_config : ClientConfig? = nil,
) : Hash(String, JSON::Any)
data = {
"context" => self.make_context(client_config),
"context" => make_context(client_config),
"params" => params,
}
return self._post_json("/youtubei/v1/get_transcript", data, client_config)
return _post_json("/youtubei/v1/get_transcript", data, client_config)
end
####################################################################
@ -602,7 +602,7 @@ module YoutubeAPI
status code #{response.status_code}. See <a href=\"https://docs.invidious.io/youtube-errors-explained/\"> \
https://docs.invidious.io/youtube-errors-explained/</a> for troubleshooting.")
end
self._decompress(response.body_io, response.headers["Content-Encoding"]?)
_decompress(response.body_io, response.headers["Content-Encoding"]?)
end
end