diff options
Diffstat (limited to 'skate/schema.go')
-rw-r--r-- | skate/schema.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/skate/schema.go b/skate/schema.go index fda2e7a..92a66f0 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -530,8 +530,23 @@ func (v OpenLibraryEdition) Isbns() []string { } // OpenLibraryEditionToRelease convert OL data into a release. XXX: release/work? -func OpenLibraryEditionToRelease(v *OpenLibraryEdition) (*Release, error) { - var release = Release{} +func OpenLibraryEditionToRelease(v *OpenLibraryEdition, authorMap map[string]string) (*Release, error) { + var ( + release Release + contribs = make([]struct { + Index int `json:"index,omitempty"` + RawName string `json:"raw_name,omitempty"` + Role string `json:"role,omitempty"` + }, len(v.Authors)) + ) + for i, author := range v.Authors { + name, ok := authorMap[author.Key] + if !ok { + continue + } + contribs[i].RawName = name + } + release.Contribs = contribs release.Title = v.Title release.ExtIDs.ISBN = v.Isbns() if len(v.Publishers) > 0 { |