1
0
mirror of https://github.com/thebaer/cdr.git synced 2024-11-15 01:31:01 +00:00

Add Num field to Track

This commit is contained in:
Matt Baer 2020-02-29 10:48:02 -05:00
parent 82650d00ae
commit 52749656f2
2 changed files with 4 additions and 0 deletions

View File

@ -26,6 +26,7 @@ var (
func newMixtape(wd string) (*cdr.Mixtape, error) { func newMixtape(wd string) (*cdr.Mixtape, error) {
m := &cdr.Mixtape{Tracks: []cdr.Track{}} m := &cdr.Mixtape{Tracks: []cdr.Track{}}
c := 1
filepath.Walk(wd, func(path string, i os.FileInfo, err error) error { filepath.Walk(wd, func(path string, i os.FileInfo, err error) error {
if !i.IsDir() && !strings.HasPrefix(i.Name(), ".") && i.Name() != "index.html" { if !i.IsDir() && !strings.HasPrefix(i.Name(), ".") && i.Name() != "index.html" {
@ -34,6 +35,8 @@ func newMixtape(wd string) (*cdr.Mixtape, error) {
log.Printf("Skipping track %s: %v", i.Name(), err) log.Printf("Skipping track %s: %v", i.Name(), err)
return nil return nil
} }
t.Num = c
c++
log.Println("Adding track", t.Title) log.Println("Adding track", t.Title)
m.Tracks = append(m.Tracks, *t) m.Tracks = append(m.Tracks, *t)
} }

View File

@ -6,6 +6,7 @@ type (
} }
Track struct { Track struct {
Num int
Title string Title string
Artist string Artist string