Make 'videoThumbnails' an array instead of an object

This commit is contained in:
Omar Roth 2018-08-05 16:54:25 -05:00
parent 7d6bc671c2
commit 0f778cbd9d

View file

@ -2081,14 +2081,14 @@ get "/api/v1/top" do |env|
json.field "title", video.title json.field "title", video.title
json.field "videoId", video.id json.field "videoId", video.id
json.field "videoThumbnails" do json.field "videoThumbnails" do
json.object do
qualities = [{name: "default", url: "default", width: 120, height: 90}, qualities = [{name: "default", url: "default", width: 120, height: 90},
{name: "high", url: "hqdefault", width: 480, height: 360}, {name: "high", url: "hqdefault", width: 480, height: 360},
{name: "medium", url: "mqdefault", width: 320, height: 180}, {name: "medium", url: "mqdefault", width: 320, height: 180},
] ]
json.array do
qualities.each do |quality| qualities.each do |quality|
json.field quality[:name] do
json.object do json.object do
json.field "quality", quality[:name]
json.field "url", "https://i.ytimg.com/vi/#{video.id}/#{quality["url"]}.jpg" json.field "url", "https://i.ytimg.com/vi/#{video.id}/#{quality["url"]}.jpg"
json.field "width", quality[:width] json.field "width", quality[:width]
json.field "height", quality[:height] json.field "height", quality[:height]
@ -2096,7 +2096,6 @@ get "/api/v1/top" do |env|
end end
end end
end end
end
json.field "lengthSeconds", video.info["length_seconds"].to_i json.field "lengthSeconds", video.info["length_seconds"].to_i
json.field "viewCount", video.views json.field "viewCount", video.views
@ -2220,14 +2219,14 @@ get "/api/v1/channels/:ucid" do |env|
json.field "published", video.published.epoch json.field "published", video.published.epoch
json.field "videoThumbnails" do json.field "videoThumbnails" do
json.object do
qualities = [{name: "default", url: "default", width: 120, height: 90}, qualities = [{name: "default", url: "default", width: 120, height: 90},
{name: "high", url: "hqdefault", width: 480, height: 360}, {name: "high", url: "hqdefault", width: 480, height: 360},
{name: "medium", url: "mqdefault", width: 320, height: 180}, {name: "medium", url: "mqdefault", width: 320, height: 180},
] ]
json.array do
qualities.each do |quality| qualities.each do |quality|
json.field quality[:name] do
json.object do json.object do
json.field "quality", quality[:name]
json.field "url", "https://i.ytimg.com/vi/#{video.id}/#{quality["url"]}.jpg" json.field "url", "https://i.ytimg.com/vi/#{video.id}/#{quality["url"]}.jpg"
json.field "width", quality[:width] json.field "width", quality[:width]
json.field "height", quality[:height] json.field "height", quality[:height]
@ -2241,7 +2240,6 @@ get "/api/v1/channels/:ucid" do |env|
end end
end end
end end
end
env.response.content_type = "application/json" env.response.content_type = "application/json"
channel_info channel_info
@ -2324,14 +2322,14 @@ get "/api/v1/channels/:ucid/videos" do |env|
json.field "videoId", video_id json.field "videoId", video_id
json.field "videoThumbnails" do json.field "videoThumbnails" do
json.object do
qualities = [{name: "default", url: "default", width: 120, height: 90}, qualities = [{name: "default", url: "default", width: 120, height: 90},
{name: "high", url: "hqdefault", width: 480, height: 360}, {name: "high", url: "hqdefault", width: 480, height: 360},
{name: "medium", url: "mqdefault", width: 320, height: 180}, {name: "medium", url: "mqdefault", width: 320, height: 180},
] ]
json.array do
qualities.each do |quality| qualities.each do |quality|
json.field quality[:name] do
json.object do json.object do
json.field "quality", quality[:name]
json.field "url", "https://i.ytimg.com/vi/#{video_id}/#{quality["url"]}.jpg" json.field "url", "https://i.ytimg.com/vi/#{video_id}/#{quality["url"]}.jpg"
json.field "width", quality[:width] json.field "width", quality[:width]
json.field "height", quality[:height] json.field "height", quality[:height]
@ -2339,7 +2337,6 @@ get "/api/v1/channels/:ucid/videos" do |env|
end end
end end
end end
end
json.field "description", description json.field "description", description
json.field "descriptionHtml", descriptionHtml json.field "descriptionHtml", descriptionHtml