summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>2023-11-14 22:39:33 -0500
committerChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>2023-12-07 09:39:03 -0500
commit8c22e6a640d458c5447fd8a841a6694f077864e4 (patch)
tree54c1f118bcceeb6a103f423d529a320767b3d231 /src
parent9e8baa35397671aabfc77f6b912c9f1829be52b6 (diff)
downloadinvidious-8c22e6a640d458c5447fd8a841a6694f077864e4.tar.gz
invidious-8c22e6a640d458c5447fd8a841a6694f077864e4.tar.bz2
invidious-8c22e6a640d458c5447fd8a841a6694f077864e4.zip
use start time and endtime for clips
Diffstat (limited to 'src')
-rw-r--r--src/invidious/routes/watch.cr16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr
index 3d935f0a..1b1169d8 100644
--- a/src/invidious/routes/watch.cr
+++ b/src/invidious/routes/watch.cr
@@ -275,6 +275,22 @@ module Invidious::Routes::Watch
return error_template(400, "Invalid clip ID") if response["error"]?
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
+ end
+
return env.redirect "/watch?v=#{video_id}&#{env.params.query}"
else
return error_template(404, "The requested clip doesn't exist")