Browse Source

Add Num field to Track

Matt Baer 3 months ago
parent
commit
52749656f2
2 changed files with 4 additions and 0 deletions
  1. 3
    0
      cmd/cdr/generate.go
  2. 1
    0
      track.go

+ 3
- 0
cmd/cdr/generate.go View File

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

+ 1
- 0
track.go View File

@@ -6,6 +6,7 @@ type (
6 6
 	}
7 7
 
8 8
 	Track struct {
9
+		Num    int
9 10
 		Title  string
10 11
 		Artist string
11 12