Skip to content

Commit

Permalink
continue when video has no formats
Browse files Browse the repository at this point in the history
  • Loading branch information
LumePart committed Feb 6, 2024
1 parent 651f7ef commit 0745c12
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ func downloadAndFormat(song string, artist string, name string, cfg Youtube) (st

// Remove illegal characters for file naming
re := regexp.MustCompile("[^a-zA-Z0-9._]+")
s := re.ReplaceAllString(song, " ")
a := re.ReplaceAllString(artist, " ")
s := re.ReplaceAllString(song, "_")
a := re.ReplaceAllString(artist, "_")

video, _ := yt_client.GetVideo(v.ID.VideoID)
formats := video.Formats.WithAudioChannels() // Get video with audio
if formats == nil {
log.Printf("video format is empty, skipping track")
break
log.Println("video format is empty, getting next one...")
continue
}
stream, _, err := yt_client.GetStream(video, &formats[2])
if err != nil {
Expand Down

0 comments on commit 0745c12

Please sign in to comment.