Skip to content

Commit

Permalink
added separate slice to append songs to m3u playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
LumePart committed Sep 9, 2024
1 parent a5fd42b commit 9e6aa6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,20 @@ func main() {

var files []string
var songs []string
var m3usongs []string

for _, track := range tracks {
song, file := gatherVideo(cfg.Youtube, track.Title, track.Artist, track.Album)
files = append(files, file)
if song != "" {
files = append(files, file) // used for deleting .webms
if song != "" { // used for creating playlists
m3usongs = append(m3usongs, file)
songs = append(songs, song)
}
}

cleanUp(cfg, files)

err := createPlaylist(cfg, songs, files, system)
err := createPlaylist(cfg, songs, m3usongs, system)
if err != nil {
log.Fatal(err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func gatherVideo(cfg Youtube, song, artist, album string) (string, string) {
log.Printf("failed getting stream: %s", err.Error())
}
}
// if getting song from topic channel fails, try getting from first available channel
// if getting song from official channel fails, try getting from first available channel
for _, video := range videos.Items {
if filter(song, artist, video.Snippet.Title) {
stream, err := getVideo(video.ID.VideoID)
Expand Down

0 comments on commit 9e6aa6b

Please sign in to comment.