mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-23 03:18:51 +00:00
Restructure API routes to use more namespaces
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module Invidious::Routes::APIv1
|
||||
module Invidious::Routes::APIv1::Channels
|
||||
def self.home(env)
|
||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||
|
||||
@@ -240,4 +240,27 @@ module Invidious::Routes::APIv1
|
||||
return error_json(500, ex)
|
||||
end
|
||||
end
|
||||
|
||||
def self.channel_search(env)
|
||||
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
|
||||
|
||||
env.response.content_type = "application/json"
|
||||
|
||||
ucid = env.params.url["ucid"]
|
||||
|
||||
query = env.params.query["q"]?
|
||||
query ||= ""
|
||||
|
||||
page = env.params.query["page"]?.try &.to_i?
|
||||
page ||= 1
|
||||
|
||||
count, search_results = channel_search(query, page, ucid)
|
||||
JSON.build do |json|
|
||||
json.array do
|
||||
search_results.each do |item|
|
||||
item.to_json(locale, json)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user