From 9153b49c8c2e2d4bb52942d71890e455f30ede8a Mon Sep 17 00:00:00 2001 From: Markus Kuuse Date: Thu, 29 Feb 2024 19:09:56 +0200 Subject: [PATCH] swapped if else to switch case --- youtube.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube.go b/youtube.go index a22223b..5866f08 100644 --- a/youtube.go +++ b/youtube.go @@ -86,10 +86,14 @@ func downloadAndFormat(song string, artist string, name string, cfg Youtube) (st continue } - if len(formats) >= 2 { // if video has audio only format use that (to save temporary space) - format = formats[2] - } else { + switch len(formats) { + case 0: + log.Println("format list is empty, getting next video...") + continue + case 1, 2: format = formats[0] + default: // if video has audio only format use that (to save space) + format = formats[2] } stream, _, err := yt_client.GetStream(video, &format)