mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-17 02:18:51 +00:00
Implement "fields" parameter from the YouTube Data API (#429)
* Implement fields handling
This commit is contained in:
@@ -97,6 +97,16 @@ class APIHandler < Kemal::Handler
|
||||
if env.response.headers["Content-Type"]?.try &.== "application/json"
|
||||
response = JSON.parse(response)
|
||||
|
||||
if env.params.query["fields"]?
|
||||
fields_text = env.params.query["fields"]
|
||||
begin
|
||||
JSONFilter.filter(response, fields_text)
|
||||
rescue ex
|
||||
env.response.status_code = 400
|
||||
response = {"error" => ex.message}
|
||||
end
|
||||
end
|
||||
|
||||
if env.params.query["pretty"]? && env.params.query["pretty"] == "1"
|
||||
response = response.to_pretty_json
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user