From f5f7e3e6d1e18a6115e517fb5e1101ea505ca367 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Sat, 22 May 2021 11:44:06 +0200 Subject: add OL edition example --- skate/fixtures/ol_edition.json | 96 ++++++++++++++++++++++++++++++++++++++++++ skate/schema.go | 62 ++++++++++++++++++++++++++- 2 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 skate/fixtures/ol_edition.json diff --git a/skate/fixtures/ol_edition.json b/skate/fixtures/ol_edition.json new file mode 100644 index 0000000..12dba0f --- /dev/null +++ b/skate/fixtures/ol_edition.json @@ -0,0 +1,96 @@ +{ + "publishers": [ + "Plume" + ], + "identifiers": { + "librarything": [ + "74028" + ], + "goodreads": [ + "194929" + ] + }, + "subtitle": "what America owes to Blacks", + "isbn_10": [ + "0452282101" + ], + "subject_place": [ + "United States", + "Africa" + ], + "pagination": "x, 262 p. ;", + "covers": [ + 297139 + ], + "lc_classifications": [ + "E185.615 .R525 2001", + "PR6060.E95T47 2000" + ], + "key": "/books/OL3382710M", + "authors": [ + { + "key": "/authors/OL30568A" + } + ], + "ocaid": "thirtynothingnov00jewe_0", + "publish_places": [ + "New York" + ], + "genres": [ + "Anecdotes." + ], + "source_records": [ + "marc:marc_loc_updates/v40.i08.records.utf8:77308:1110", + "ia:debtwhatamericao00robi_986", + "ia:thirtynothingnov00jewe_0", + "marc:marc_loc_2016/BooksAll.2016.part01.utf8:24066620:1110", + "bwb:9780452282100", + "marc:marc_loc_2016/BooksAll.2016.part32.utf8:98898789:965" + ], + "title": "The debt", + "dewey_decimal_class": [ + "305.8/00973" + ], + "notes": { + "type": "/type/text", + "value": "Includes bibliographical references (p. 249-252) and index.\nOriginally published: New York : Dutton, c2000." + }, + "number_of_pages": 262, + "languages": [ + { + "key": "/languages/eng" + } + ], + "lccn": [ + "2004556979" + ], + "subjects": [ + "Robinson, Randall, 1941- -- Anecdotes.", + "African Americans -- Civil rights.", + "African Americans -- Social conditions.", + "African Americans -- Claims.", + "United States -- Race relations.", + "Africa -- Civilization." + ], + "publish_date": "2001", + "publish_country": "nyu", + "by_statement": "Randall Robinson.", + "works": [ + { + "key": "/works/OL488811W" + } + ], + "type": { + "key": "/type/edition" + }, + "latest_revision": 14, + "revision": 14, + "created": { + "type": "/type/datetime", + "value": "2008-04-01T03:28:50.625462" + }, + "last_modified": { + "type": "/type/datetime", + "value": "2020-12-11T02:54:01.552846" + } +} diff --git a/skate/schema.go b/skate/schema.go index f97b55a..42587b9 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -426,8 +426,8 @@ type OpenLibraryWork struct { Version int64 `json:"_version_"` } -// OpenLibraryToRelease convert OL data into a release. XXX: release/work? -func OpenLibraryToRelease(w *OpenLibraryWork) (*Release, error) { +// OpenLibraryWorkToRelease convert OL data into a release. XXX: release/work? +func OpenLibraryWorkToRelease(w *OpenLibraryWork) (*Release, error) { var ( release Release contribs = make([]struct { @@ -462,3 +462,61 @@ func OpenLibraryToRelease(w *OpenLibraryWork) (*Release, error) { release.Extra.OpenLibrary.HasFulltext = w.HasFulltext return &release, nil } + +type OpenLibraryEdition struct { + Authors []struct { + Key string `json:"key"` + } `json:"authors"` + ByStatement string `json:"by_statement"` + Covers []int64 `json:"covers"` + Created struct { + Type string `json:"type"` + Value string `json:"value"` + } `json:"created"` + DeweyDecimalClass []string `json:"dewey_decimal_class"` + Genres []string `json:"genres"` + Identifiers struct { + Goodreads []string `json:"goodreads"` + Librarything []string `json:"librarything"` + } `json:"identifiers"` + Isbn10 []string `json:"isbn_10"` + Key string `json:"key"` + Languages []struct { + Key string `json:"key"` + } `json:"languages"` + LastModified struct { + Type string `json:"type"` + Value string `json:"value"` + } `json:"last_modified"` + LatestRevision int64 `json:"latest_revision"` + LcClassifications []string `json:"lc_classifications"` + Lccn []string `json:"lccn"` + Notes struct { + Type string `json:"type"` + Value string `json:"value"` + } `json:"notes"` + NumberOfPages int64 `json:"number_of_pages"` + Ocaid string `json:"ocaid"` + Pagination string `json:"pagination"` + PublishCountry string `json:"publish_country"` + PublishDate string `json:"publish_date"` + PublishPlaces []string `json:"publish_places"` + Publishers []string `json:"publishers"` + Revision int64 `json:"revision"` + SourceRecords []string `json:"source_records"` + SubjectPlace []string `json:"subject_place"` + Subjects []string `json:"subjects"` + Subtitle string `json:"subtitle"` + Title string `json:"title"` + Type struct { + Key string `json:"key"` + } `json:"type"` + Works []struct { + Key string `json:"key"` + } `json:"works"` +} + +// OpenLibraryEditionToRelease convert OL data into a release. XXX: release/work? +func OpenLibraryEditionToRelease(w *OpenLibraryEdition) (*Release, error) { + return nil, nil +} -- cgit v1.2.3