Invidious is an alternative front-end to YouTube
Simplify resolveUrl api call
ChunkyProgrammer734f1b776459
diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.crindex 85ddff35..76dab361 100644--- a/src/invidious/channels/community.cr+++ b/src/invidious/channels/community.cr@@ -24,12 +24,12 @@ def fetch_channel_community(ucid, cursor, locale, format, thin_mode)return extract_channel_community(items, ucid: ucid, locale: locale, format: format, thin_mode: thin_mode)end-def fetch_channel_community_post(ucid, postId, locale, format, thin_mode, params : String | Nil = nil)+def fetch_channel_community_post(ucid, post_id, locale, format, thin_mode, params : String | Nil = nil)if params.nil?object = {"2:string" => "community","25:embedded" => {- "22:string" => postId.to_s,+ "22:string" => post_id.to_s,},"45:embedded" => {"2:varint" => 1_i64,diff --git a/src/invidious/comments/youtube.cr b/src/invidious/comments/youtube.crindex da7f0543..01c2564f 100644--- a/src/invidious/comments/youtube.cr+++ b/src/invidious/comments/youtube.cr@@ -16,11 +16,11 @@ module Invidious::Commentsreturn parse_youtube(id, response, format, locale, thin_mode, sort_by)end- def fetch_community_post_comments(ucid, postId)+ def fetch_community_post_comments(ucid, post_id)object = {"2:string" => "community","25:embedded" => {- "22:string" => postId,+ "22:string" => post_id,},"45:embedded" => {"2:varint" => 1_i64,@@ -30,7 +30,7 @@ module Invidious::Comments"4:embedded" => {"6:varint" => 0_i64,"27:varint" => 1_i64,- "29:string" => postId,+ "29:string" => post_id,"30:string" => ucid,},"8:string" => "comments-section",diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.crindex 91a62fa3..6118a0d1 100644--- a/src/invidious/routes/api/v1/misc.cr+++ b/src/invidious/routes/api/v1/misc.cr@@ -162,16 +162,15 @@ module Invidious::Routes::API::V1::Miscresolved_url = YoutubeAPI.resolve_url(url.as(String))endpoint = resolved_url["endpoint"]pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""- if sub_endpoint = endpoint.dig?("watchEndpoint")- resolved_ucid = sub_endpoint.dig?("videoId")- elsif sub_endpoint = endpoint.dig?("browseEndpoint")- resolved_ucid = sub_endpoint.dig?("browseId")+ if sub_endpoint = endpoint["watchEndpoint"]?+ resolved_ucid = sub_endpoint["videoId"]?+ elsif sub_endpoint = endpoint["browseEndpoint"]?+ resolved_ucid = sub_endpoint["browseId"]?elsif pageType == "WEB_PAGE_TYPE_UNKNOWN"return error_json(400, "Unknown url")end- if !sub_endpoint.nil?- params = sub_endpoint.dig?("params")- end++ params = sub_endpoint.try &.dig?("params")rescue exreturn error_json(500, ex)enddiff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.crindex 1d02ee08..8515b910 100644--- a/src/invidious/routes/channels.cr+++ b/src/invidious/routes/channels.cr@@ -161,7 +161,7 @@ module Invidious::Routes::Channels# redirect to post pageif lb = env.params.query["lb"]?- env.redirect "/post/#{lb}?ucid=#{ucid}"+ env.redirect "/post/#{URI.encode_www_form(lb)}?ucid=#{URI.encode_www_form(ucid)}"endthin_mode = env.params.query["thin_mode"]? || env.get("preferences").as(Preferences).thin_mode