Add API endpoint for Clips

This commit is contained in:
ChunkyProgrammer
2023-11-14 23:35:11 -05:00
parent 8c22e6a640
commit b344d98c25
4 changed files with 67 additions and 13 deletions

View File

@@ -276,19 +276,9 @@ module Invidious::Routes::Watch
if video_id = response.dig?("endpoint", "watchEndpoint", "videoId")
if params = response.dig?("endpoint", "watchEndpoint", "params").try &.as_s
decoded_protobuf = params.try { |i| URI.decode_www_form(i) }
.try { |i| Base64.decode(i) }
.try { |i| IO::Memory.new(i) }
.try { |i| Protodec::Any.parse(i) }
start_time = decoded_protobuf
.try(&.["50:0:embedded"]["2:1:varint"].as_i64)
end_time = decoded_protobuf
.try(&.["50:0:embedded"]["3:2:varint"].as_i64)
env.params.query["start"] = (start_time / 1000).to_s
env.params.query["end"] = (end_time / 1000).to_s
start_time, end_time, _ = parse_clip_parameters(params)
env.params.query["start"] = start_time.to_s
env.params.query["end"] = end_time.to_s
end
return env.redirect "/watch?v=#{video_id}&#{env.params.query}"