Skip to content

Commit

Permalink
swapped if else to switch case
Browse files Browse the repository at this point in the history
  • Loading branch information
LumePart committed Feb 29, 2024
1 parent 0ad5e7a commit 9153b49
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9153b49

Please sign in to comment.