mirror of
https://github.com/thebaer/cdr.git
synced 2024-11-14 17:21:01 +00:00
Clean filenames without track numbers
Previously, we'd fail if files had no numbers. Now this ignores and continues anyway.
This commit is contained in:
parent
48ff27f671
commit
d49fde1263
@ -41,15 +41,16 @@ func RenameTrack(file string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
ext := t.Filename[strings.LastIndex(t.Filename, "."):]
|
||||
|
||||
// Extract playlist track number from filename
|
||||
fMatch := trackNameReg.FindStringSubmatch(t.Filename)
|
||||
if len(fMatch) < 2 {
|
||||
log.Fatal("Unexpect filename format")
|
||||
log.Printf("No track number found: '%s'. Continuing anyway.\n", t.Filename)
|
||||
return fmt.Sprintf("%s-%s%s", Sanitize(t.Artist), Sanitize(t.Title), ext)
|
||||
}
|
||||
|
||||
trackNum := fMatch[1]
|
||||
|
||||
ext := t.Filename[strings.LastIndex(t.Filename, "."):]
|
||||
|
||||
return fmt.Sprintf("%s-%s-%s%s", trackNum, Sanitize(t.Artist), Sanitize(t.Title), ext)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user