Browse Source
api: Add support for the "featured channels" endpoint
pull/3419/head
Samantaz Fox
3 years ago
No known key found for this signature in database
GPG Key ID: F42821059186176E
2 changed files with
32 additions and
0 deletions
-
src/invidious/routes/api/v1/channels.cr
-
src/invidious/routing.cr
|
|
|
@ -283,6 +283,37 @@ module Invidious::Routes::API::V1::Channels |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def self.channels(env) |
|
|
|
locale = env.get("preferences").as(Preferences).locale |
|
|
|
ucid = env.params.url["ucid"] |
|
|
|
|
|
|
|
env.response.content_type = "application/json" |
|
|
|
|
|
|
|
# Use the macro defined above |
|
|
|
channel = nil # Make the compiler happy |
|
|
|
get_channel() |
|
|
|
|
|
|
|
continuation = env.params.query["continuation"]? |
|
|
|
|
|
|
|
begin |
|
|
|
items, next_continuation = fetch_related_channels(channel, continuation) |
|
|
|
rescue ex |
|
|
|
return error_json(500, ex) |
|
|
|
end |
|
|
|
|
|
|
|
JSON.build do |json| |
|
|
|
json.object do |
|
|
|
json.field "relatedChannels" do |
|
|
|
json.array do |
|
|
|
items.each &.to_json(locale, json) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
json.field "continuation", next_continuation if next_continuation |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def self.search(env) |
|
|
|
locale = env.get("preferences").as(Preferences).locale |
|
|
|
region = env.params.query["region"]? |
|
|
|
|
|
|
|
@ -225,6 +225,7 @@ module Invidious::Routing |
|
|
|
get "/api/v1/channels/:ucid", {{namespace}}::Channels, :home |
|
|
|
get "/api/v1/channels/:ucid/shorts", {{namespace}}::Channels, :shorts |
|
|
|
get "/api/v1/channels/:ucid/streams", {{namespace}}::Channels, :streams |
|
|
|
get "/api/v1/channels/:ucid/channels", {{namespace}}::Channels, :channels |
|
|
|
|
|
|
|
{% for route in {"videos", "latest", "playlists", "community", "search"} %} |
|
|
|
get "/api/v1/channels/#{{{route}}}/:ucid", {{namespace}}::Channels, :{{route}} |
|
|
|
|