History

better discnumber/totaldiscs handling

Sigrid Solveig Haflínudóttir committed 7 years ago

Commit d8ea5981 parent bb928452 files · +20 −10Browse files

Unified · Split

2 files
  1. input.go +18 −8
  2. track.go +2 −2
input.go+18−8
@@ -6,6 +6,7 @@ import ( · 5 unmodified lines
6 "io"6 "io"
7 "os"7 "os"
8 "path/filepath"8 "path/filepath"
9 "strconv"
9 "strings"10 "strings"
10 11
11 "github.com/ftrvxmtrx/chub/cue"12 "github.com/ftrvxmtrx/chub/cue"
@@ -73,7 +74,6 @@ func NewInput(path string) (in *Input, err error) { · 61 unmodified lines
73 err = fmt.Errorf("%s: %s", f.Name, err)74 err = fmt.Errorf("%s: %s", f.Name, err)
74 return75 return
75 }76 }
76 in.TotalDisks++
77 in.Audio = append(in.Audio, audio)77 in.Audio = append(in.Audio, audio)
78 filesFromCue = append(filesFromCue, f)78 filesFromCue = append(filesFromCue, f)
79 }79 }
@@ -85,16 +85,26 @@ func NewInput(path string) (in *Input, err error) { · 5 unmodified lines
85 in.SongWriter = sheet.Songwriter85 in.SongWriter = sheet.Songwriter
86 in.Title = sheet.Title86 in.Title = sheet.Title
87 87
88 var diskNumber int
88 for _, c := range sheet.Comments {89 for _, c := range sheet.Comments {
89 if strings.HasPrefix(c, "DATE") {90 if words := strings.SplitAfterN(c, " ", 2); len(words) < 2 {
90 words := strings.Fields(c)91 continue
91 in.Date = words[len(words)-1]92 } else if strings.HasPrefix(c, "DATE") {
93 in.Date = words[1]
92 } else if strings.HasPrefix(c, "GENRE") {94 } else if strings.HasPrefix(c, "GENRE") {
93 words := strings.SplitAfterN(c, " ", 2)
94 in.Genre = words[1]95 in.Genre = words[1]
95 } else if strings.HasPrefix(c, "COMPOSER") {96 } else if strings.HasPrefix(c, "COMPOSER") {
96 words := strings.SplitAfterN(c, " ", 2)
97 in.Composer = words[1]97 in.Composer = words[1]
98 } else if len(in.Audio) == 1 {
99 // FIXME no idea what to do with several discnumber comments in a cue sheet
100 if strings.HasPrefix(c, "DISCNUMBER") {
101 diskNumber, err = strconv.Atoi(words[1])
102 } else if strings.HasPrefix(c, "TOTALDISCS") {
103 in.TotalDisks, err = strconv.Atoi(words[1])
104 }
105 }
106 if err != nil {
107 return
98 }108 }
99 }109 }
100 110
@@ -121,8 +131,8 @@ func NewInput(path string) (in *Input, err error) { · 20 unmodified lines
121 Genre: in.Genre,131 Genre: in.Genre,
122 Date: in.Date,132 Date: in.Date,
123 TotalTracks: &in.TotalTracks,133 TotalTracks: &in.TotalTracks,
124 TotalDisks: &in.TotalDisks,134 TotalDisks: in.TotalDisks,
125 DiskNumber: i + 1,135 DiskNumber: diskNumber,
126 }136 }
127 for _, c := range ft.Comments {137 for _, c := range ft.Comments {
128 if strings.HasPrefix(c, "COMPOSER") {138 if strings.HasPrefix(c, "COMPOSER") {
track.go+2−2
@@ -8,9 +8,9 @@ import ( · 7 unmodified lines
8 8
9type Track struct {9type Track struct {
10 Number int `json:"number,omitempty"`10 Number int `json:"number,omitempty"`
11 DiskNumber int `json:"diskNumber"`11 DiskNumber int `json:"diskNumber,omitempty"`
12 TotalTracks *int `json:"totalTracks"`12 TotalTracks *int `json:"totalTracks"`
13 TotalDisks *int `json:"totalDisks"`13 TotalDisks int `json:"totalDisks,omitempty"`
14 Composer string `json:"composer,omitempty"`14 Composer string `json:"composer,omitempty"`
15 Performer string `json:"performer,omitempty"`15 Performer string `json:"performer,omitempty"`
16 SongWriter string `json:"songWriter,omitempty"`16 SongWriter string `json:"songWriter,omitempty"`

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t