|
|
@ -55,4 +55,34 @@ module Invidious::Routes::API::V1::Search
|
|
|
|
return error_json(500, ex)
|
|
|
|
return error_json(500, ex)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def self.hashtag(env)
|
|
|
|
|
|
|
|
hashtag = env.params.url["hashtag"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# page does not change anything.
|
|
|
|
|
|
|
|
# page = env.params.query["page"]?.try &.to_i?|| 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
page = 1
|
|
|
|
|
|
|
|
locale = env.get("preferences").as(Preferences).locale
|
|
|
|
|
|
|
|
region = env.params.query["region"]?
|
|
|
|
|
|
|
|
env.response.content_type = "application/json"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
results = Invidious::Hashtag.fetch(hashtag, page, region)
|
|
|
|
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
return error_json(400, ex)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSON.build do |json|
|
|
|
|
|
|
|
|
json.object do
|
|
|
|
|
|
|
|
json.field "results" do
|
|
|
|
|
|
|
|
json.array do
|
|
|
|
|
|
|
|
results.each do |item|
|
|
|
|
|
|
|
|
item.to_json(locale, json)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|