@@ -399,50 +399,17 @@ Invidious::Routing.get "/s_p/:id/:name", Invidious::Routes::Images, :s_p_image
399399Invidious ::Routing .get " /yts/img/:name" , Invidious ::Routes ::Images , :yts_image
400400Invidious ::Routing .get " /vi/:id/:name" , Invidious ::Routes ::Images , :thumbnails
401401
402+ Invidious ::Routing .get " /channel/:ucid/live" , Invidious ::Routes ::Live , :check
403+ Invidious ::Routing .get " /user/:user/live" , Invidious ::Routes ::Live , :check
404+ Invidious ::Routing .get " /c/:user/live" , Invidious ::Routes ::Live , :check
405+
402406# API routes (macro)
403407define_v1_api_routes()
404408
405409# Video playback (macros)
406410define_api_manifest_routes()
407411define_video_playback_routes()
408412
409- # Channels
410-
411- {" /channel/:ucid/live" , " /user/:user/live" , " /c/:user/live" }.each do |route |
412- get route do |env |
413- locale = env.get(" preferences" ).as(Preferences ).locale
414-
415- # Appears to be a bug in routing, having several routes configured
416- # as `/a/:a`, `/b/:a`, `/c/:a` results in 404
417- value = env.request.resource.split(" /" )[2 ]
418- body = " "
419- {" channel" , " user" , " c" }.each do |type |
420- response = YT_POOL .client & .get(" /#{ type } /#{ value } /live?disable_polymer=1" )
421- if response.status_code == 200
422- body = response.body
423- end
424- end
425-
426- video_id = body.match(/'VIDEO_ID': "(?<id>[a-zA-Z0-9_-] {11} ) "/ ).try & .[" id" ]?
427- if video_id
428- params = [] of String
429- env.params.query.each do |k , v |
430- params << " #{ k } =#{ v } "
431- end
432- params = params.join(" &" )
433-
434- url = " /watch?v=#{ video_id } "
435- if ! params.empty?
436- url += " &#{ params } "
437- end
438-
439- env.redirect url
440- else
441- env.redirect " /channel/#{ value } "
442- end
443- end
444- end
445-
446413# Authenticated endpoints
447414
448415# The notification APIs can't be extracted yet
0 commit comments