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,18 +2081,17 @@ 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]
end
end end
end end
end end
@ -2220,18 +2219,17 @@ 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]
end
end end
end end
end end
@ -2324,18 +2322,17 @@ 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]
end
end end
end end
end end