@@ -154,8 +154,8 @@ if CONFIG.popular_enabled
154154 Invidious ::Jobs .register Invidious ::Jobs ::PullPopularVideosJob .new(PG_DB )
155155end
156156
157- connection_channel = Channel ({Bool , Channel (PQ ::Notification )}).new(32 )
158- Invidious ::Jobs .register Invidious ::Jobs ::NotificationJob .new(connection_channel , CONFIG .database_url)
157+ CONNECTION_CHANNEL = Channel ({Bool , Channel (PQ ::Notification )}).new(32 )
158+ Invidious ::Jobs .register Invidious ::Jobs ::NotificationJob .new(CONNECTION_CHANNEL , CONFIG .database_url)
159159
160160Invidious ::Jobs .start_all
161161
360360 Invidious ::Routing .post " /playlist_ajax" , Invidious ::Routes ::Playlists , :playlist_ajax
361361 Invidious ::Routing .get " /playlist" , Invidious ::Routes ::Playlists , :show
362362 Invidious ::Routing .get " /mix" , Invidious ::Routes ::Playlists , :mix
363+ Invidious ::Routing .get " /watch_videos" , Invidious ::Routes ::Playlists , :watch_videos
363364
364365 Invidious ::Routing .get " /opensearch.xml" , Invidious ::Routes ::Search , :opensearch
365366 Invidious ::Routing .get " /results" , Invidious ::Routes ::Search , :results
390391
391392 Invidious ::Routing .post " /subscription_ajax" , Invidious ::Routes ::Subscriptions , :toggle_subscription
392393 Invidious ::Routing .get " /subscription_manager" , Invidious ::Routes ::Subscriptions , :subscription_manager
394+
395+ Invidious ::Routing .get " /Captcha" , Invidious ::Routes ::Captcha , :get
393396{% end % }
394397
395398Invidious ::Routing .get " /ggpht/*" , Invidious ::Routes ::Images , :ggpht
@@ -405,53 +408,13 @@ Invidious::Routing.get "/c/:user/live", Invidious::Routes::Live, :check
405408
406409# API routes (macro)
407410define_v1_api_routes()
411+ Invidious ::Routing .get " /api/v1/auth/notifications" , Invidious ::Routes ::API ::V1 ::Authenticated , :notifications_get
412+ Invidious ::Routing .post " /api/v1/auth/notifications" , Invidious ::Routes ::API ::V1 ::Authenticated , :notifications_post
408413
409414# Video playback (macros)
410415define_api_manifest_routes()
411416define_video_playback_routes()
412417
413- # Authenticated endpoints
414-
415- # The notification APIs can't be extracted yet
416- # due to the requirement of the `connection_channel`
417- # used by the `NotificationJob`
418-
419- get " /api/v1/auth/notifications" do |env |
420- env.response.content_type = " text/event-stream"
421-
422- topics = env.params.query[" topics" ]?.try & .split(" ," ).uniq.first(1000 )
423- topics ||= [] of String
424-
425- create_notification_stream(env, topics, connection_channel)
426- end
427-
428- post " /api/v1/auth/notifications" do |env |
429- env.response.content_type = " text/event-stream"
430-
431- topics = env.params.body[" topics" ]?.try & .split(" ," ).uniq.first(1000 )
432- topics ||= [] of String
433-
434- create_notification_stream(env, topics, connection_channel)
435- end
436-
437- get " /Captcha" do |env |
438- headers = HTTP ::Headers {" :authority" => " accounts.google.com" }
439- response = YT_POOL .client & .get(env.request.resource, headers)
440- env.response.headers[" Content-Type" ] = response.headers[" Content-Type" ]
441- response.body
442- end
443-
444- # Undocumented, creates anonymous playlist with specified 'video_ids', max 50 videos
445- get " /watch_videos" do |env |
446- response = YT_POOL .client & .get(env.request.resource)
447- if url = response.headers[" Location" ]?
448- url = URI .parse(url).request_target
449- next env.redirect url
450- end
451-
452- env.response.status_code = response.status_code
453- end
454-
455418error 404 do |env |
456419 if md = env.request.path.match(/^\/ (?<id>([a-zA-Z0-9_-] {11} ) |(\w +) ) $/ )
457420 item = md[" id" ]
0 commit comments