File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 339339 Invidious ::Routing .post " /watch_ajax" , Invidious ::Routes ::Watch , :mark_watched
340340 Invidious ::Routing .get " /watch/:id" , Invidious ::Routes ::Watch , :redirect
341341 Invidious ::Routing .get " /shorts/:id" , Invidious ::Routes ::Watch , :redirect
342+ Invidious ::Routing .get " /clip/:clip" , Invidious ::Routes ::Watch , :clip
342343 Invidious ::Routing .get " /w/:id" , Invidious ::Routes ::Watch , :redirect
343344 Invidious ::Routing .get " /v/:id" , Invidious ::Routes ::Watch , :redirect
344345 Invidious ::Routing .get " /e/:id" , Invidious ::Routes ::Watch , :redirect
Original file line number Diff line number Diff line change @@ -266,4 +266,19 @@ module Invidious::Routes::Watch
266266 " {}"
267267 end
268268 end
269+
270+ def self.clip (env )
271+ clip_id = env.params.url[" clip" ]?
272+
273+ return error_template(400 , " A clip ID is required" ) if ! clip_id
274+
275+ response = YoutubeAPI .resolve_url(" https://www.youtube.com/clip/#{ clip_id } " )
276+ return error_template(400 , " Invalid clip ID" ) if response[" error" ]?
277+
278+ if video_id = response.dig?(" endpoint" , " watchEndpoint" , " videoId" )
279+ return env.redirect " /watch?v=#{ video_id } &#{ env.params.query } "
280+ else
281+ return error_template(404 , " The requested clip doesn't exist" )
282+ end
283+ end
269284end
You can’t perform that action at this time.
0 commit comments