From ca2320f17fabacdd050283ea293a15f46340a7be Mon Sep 17 00:00:00 2001
From: Omar Roth <omarroth@hotmail.com>
Date: Mon, 6 Aug 2018 07:24:24 -0500
Subject: [PATCH] Change 'videoThumbnails' to an array everywhere

---
 src/invidious.cr | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/invidious.cr b/src/invidious.cr
index 9b26b889..6b1be6ed 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -1971,10 +1971,12 @@ get "/api/v1/videos/:id" do |env|
                   ]
                   json.array do
                     qualities.each do |quality|
-                      json.field "quality", quality[:name]
-                      json.field "url", "https://i.ytimg.com/vi/#{rv["id"]}/#{quality["url"]}.jpg"
-                      json.field "width", quality[:width]
-                      json.field "height", quality[:height]
+                      json.object do
+                        json.field "quality", quality[:name]
+                        json.field "url", "https://i.ytimg.com/vi/#{rv["id"]}/#{quality["url"]}.jpg"
+                        json.field "width", quality[:width]
+                        json.field "height", quality[:height]
+                      end
                     end
                   end
                 end
@@ -2403,18 +2405,17 @@ get "/api/v1/search" do |env|
           json.field "authorUrl", "/channel/#{video.ucid}"
 
           json.field "videoThumbnails" do
-            json.object do
-              qualities = [{name: "default", url: "default", width: 120, height: 90},
-                           {name: "high", url: "hqdefault", width: 480, height: 360},
-                           {name: "medium", url: "mqdefault", width: 320, height: 180},
-              ]
+            qualities = [{name: "default", url: "default", width: 120, height: 90},
+                         {name: "high", url: "hqdefault", width: 480, height: 360},
+                         {name: "medium", url: "mqdefault", width: 320, height: 180},
+            ]
+            json.array do
               qualities.each do |quality|
-                json.field quality[:name] do
-                  json.object do
-                    json.field "url", "https://i.ytimg.com/vi/#{video.id}/#{quality["url"]}.jpg"
-                    json.field "width", quality[:width]
-                    json.field "height", quality[:height]
-                  end
+                json.object do
+                  json.field "quality", quality[:name]
+                  json.field "url", "https://i.ytimg.com/vi/#{video.id}/#{quality["url"]}.jpg"
+                  json.field "width", quality[:width]
+                  json.field "height", quality[:height]
                 end
               end
             end