summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious/comments.cr3
-rw-r--r--src/invidious/helpers/serialized_yt_data.cr1
-rw-r--r--src/invidious/routes/api/v1/channels.cr2
-rw-r--r--src/invidious/routes/api/v1/misc.cr27
-rw-r--r--src/invidious/routing.cr1
-rw-r--r--src/invidious/trending.cr7
6 files changed, 38 insertions, 3 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index d691ca36..357a461c 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -181,6 +181,8 @@ def fetch_youtube_comments(id, cursor, format, locale, thin_mode, region, sort_b
json.field "content", html_to_content(content_html)
json.field "contentHtml", content_html
+ json.field "isPinned", (node_comment["pinnedCommentBadge"]? != nil)
+
json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
@@ -670,6 +672,7 @@ def content_to_comment_html(content, video_id : String? = "")
end
text = "<b>#{text}</b>" if run["bold"]?
+ text = "<s>#{text}</s>" if run["strikethrough"]?
text = "<i>#{text}</i>" if run["italics"]?
text
diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.cr
index 635f0984..c1874780 100644
--- a/src/invidious/helpers/serialized_yt_data.cr
+++ b/src/invidious/helpers/serialized_yt_data.cr
@@ -74,6 +74,7 @@ struct SearchVideo
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
+ json.field "authorVerified", self.author_verified
json.field "videoThumbnails" do
Invidious::JSONify::APIv1.thumbnails(json, self.id)
diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr
index ca2b2734..bcb4db2c 100644
--- a/src/invidious/routes/api/v1/channels.cr
+++ b/src/invidious/routes/api/v1/channels.cr
@@ -89,6 +89,8 @@ module Invidious::Routes::API::V1::Channels
json.field "descriptionHtml", channel.description_html
json.field "allowedRegions", channel.allowed_regions
+ json.field "tabs", channel.tabs
+ json.field "authorVerified", channel.verified
json.field "latestVideos" do
json.array do
diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr
index 43d360e6..e499f4d6 100644
--- a/src/invidious/routes/api/v1/misc.cr
+++ b/src/invidious/routes/api/v1/misc.cr
@@ -150,4 +150,31 @@ module Invidious::Routes::API::V1::Misc
response
end
+
+ # resolve channel and clip urls, return the UCID
+ def self.resolve_url(env)
+ env.response.content_type = "application/json"
+ url = env.params.query["url"]?
+
+ return error_json(400, "Missing URL to resolve") if !url
+
+ begin
+ resolved_url = YoutubeAPI.resolve_url(url.as(String))
+ endpoint = resolved_url["endpoint"]
+ pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
+ if resolved_ucid = endpoint.dig?("watchEndpoint", "videoId")
+ elsif resolved_ucid = endpoint.dig?("browseEndpoint", "browseId")
+ elsif pageType == "WEB_PAGE_TYPE_UNKNOWN"
+ return error_json(400, "Unknown url")
+ end
+ rescue ex
+ return error_json(500, ex)
+ end
+ JSON.build do |json|
+ json.object do
+ json.field "ucid", resolved_ucid.try &.as_s || ""
+ json.field "pageType", pageType
+ end
+ end
+ end
end
diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr
index d5766b90..dca2f117 100644
--- a/src/invidious/routing.cr
+++ b/src/invidious/routing.cr
@@ -284,6 +284,7 @@ module Invidious::Routing
get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist
get "/api/v1/auth/playlists/:plid", {{namespace}}::Misc, :get_playlist
get "/api/v1/mixes/:rdid", {{namespace}}::Misc, :mixes
+ get "/api/v1/resolveurl", {{namespace}}::Misc, :resolve_url
{% end %}
end
end
diff --git a/src/invidious/trending.cr b/src/invidious/trending.cr
index 1f957081..134eb437 100644
--- a/src/invidious/trending.cr
+++ b/src/invidious/trending.cr
@@ -4,11 +4,12 @@ def fetch_trending(trending_type, region, locale)
plid = nil
- if trending_type == "Music"
+ case trending_type.try &.downcase
+ when "music"
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
- elsif trending_type == "Gaming"
+ when "gaming"
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
- elsif trending_type == "Movies"
+ when "movies"
params = "4gIKGgh0cmFpbGVycw%3D%3D"
else # Default
params = ""