Skip to content

Commit

Permalink
Fixes expression of 5 inch records
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed May 24, 2020
1 parent 7b00804 commit 640960f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Binary file modified cdtests/12182265.data
Binary file not shown.
4 changes: 3 additions & 1 deletion recordutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"log"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -50,7 +51,7 @@ func getFormatAndDisk(t *pbgd.Track) (string, int) {
return "CD", disk
}

if strings.HasPrefix(baselines[0], "7\"") {
if strings.HasPrefix(baselines[0], "7\"") || strings.HasPrefix(baselines[0], "5\"") {
if len(baselines[0]) > 2 {
disk, _ := strconv.Atoi(baselines[0][2:])
return "Vinyl", disk
Expand Down Expand Up @@ -130,6 +131,7 @@ func TrackExtract(r *pbgd.Release) []*TrackSet {
for _, track := range flatten(r.Tracklist) {
if track.TrackType == pbgd.Track_TRACK {
format, disk := getFormatAndDisk(track)
log.Printf("HERE %v, %v", format, disk)
if format == "Unknown" {
format = baseFormat
}
Expand Down
25 changes: 25 additions & 0 deletions recordutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,3 +898,28 @@ func TestRunExtractBaird(t *testing.T) {

log.Printf("WHAT %+v", tracks[len(tracks)-1])
}

func TestRunExtractHaint(t *testing.T) {
data, err := ioutil.ReadFile("cdtests/12182265.data")

if err != nil {
t.Fatalf("Error: %v", err)
}

record := &pbrc.Record{}
proto.Unmarshal(data, record)

tracks := TrackExtract(record.GetRelease())

if len(tracks) != 4 {
for i, tr := range tracks {
log.Printf("%v-%v. %v (%v-%v)", i, tr.Position, len(tr.tracks), tr.Format, tr.Disk)
for j, trs := range tr.tracks {
log.Printf(" %v. %v", j, trs.Title)
}
}
t.Errorf("Bad spec: %v -> %v", len(tracks), tracks[1].Position)
}

log.Printf("WHAT %+v", tracks[len(tracks)-1])
}

0 comments on commit 640960f

Please sign in to comment.