Restructure API routes to use more namespaces

This commit is contained in:
syeopite
2021-08-13 23:35:03 -07:00
parent 6aa65593ef
commit b3426fdc94
6 changed files with 42 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
module Invidious::Routes::APIv1
module Invidious::Routes::APIv1::Search
def self.search(env)
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
region = env.params.query["region"]?
@@ -42,29 +42,6 @@ module Invidious::Routes::APIv1
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
def self.search_suggestions(env)
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
region = env.params.query["region"]?