Invidious is an alternative front-end to YouTube
update resolve_url api to better support new post endpoint
ChunkyProgrammer4155f15bf73e
diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.crindex 4f5b58da..40f2a439 100644--- a/src/invidious/routes/api/v1/misc.cr+++ b/src/invidious/routes/api/v1/misc.cr@@ -190,15 +190,30 @@ module Invidious::Routes::API::V1::Miscsub_endpoint = endpoint["watchEndpoint"]? || endpoint["browseEndpoint"]? || endpointparams = sub_endpoint.try &.dig?("params")++ if sub_endpoint["browseId"]?.try &.as_s == "FEpost_detail"+ decoded_protobuf = params.try &.as_s.try { |i| URI.decode_www_form(i) }+ .try { |i| Base64.decode(i) }+ .try { |i| IO::Memory.new(i) }+ .try { |i| Protodec::Any.parse(i) }++ ucid = decoded_protobuf.try(&.["56:0:embedded"]["2:0:string"].as_s)+ post_id = decoded_protobuf.try(&.["56:0:embedded"]["3:1:string"].as_s)+ else+ ucid = sub_endpoint["browseId"]? if sub_endpoint["browseId"]? && sub_endpoint["browseId"]?.try &.as_s.starts_with? "UC"+ post_id = nil+ endrescue exreturn error_json(500, ex)endJSON.build do |json|json.object do- json.field "ucid", sub_endpoint["browseId"].as_s if sub_endpoint["browseId"]?+ json.field "browseId", sub_endpoint["browseId"].as_s if sub_endpoint["browseId"]?+ json.field "ucid", ucid if ucid != niljson.field "videoId", sub_endpoint["videoId"].as_s if sub_endpoint["videoId"]?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 "postId", post_id if post_id != niljson.field "params", params.try &.as_sjson.field "pageType", page_typeend