aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-05-27 00:16:32 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-05-27 00:16:32 +0200
commitcecfa8b4c42182fbe50c10eefd92bf2b57faef66 (patch)
treece9cbaecdc14742153a40e1102d22876aa7806f7 /skate
parent07a7ef5ed76aab35c07dc5c589402a5dd0cf5405 (diff)
downloadrefcat-cecfa8b4c42182fbe50c10eefd92bf2b57faef66.tar.gz
refcat-cecfa8b4c42182fbe50c10eefd92bf2b57faef66.zip
add best effort flag
Diffstat (limited to 'skate')
-rw-r--r--skate/cmd/skate-conv/main.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/skate/cmd/skate-conv/main.go b/skate/cmd/skate-conv/main.go
index a2c85a3..850d0d5 100644
--- a/skate/cmd/skate-conv/main.go
+++ b/skate/cmd/skate-conv/main.go
@@ -22,6 +22,7 @@ import (
var (
numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers")
batchSize = flag.Int("b", 100000, "batch size")
+ bestEffort = flag.Bool("B", false, "only log errors, do not halt")
fromFormat = flag.String("f", "ref", "import schema: ref, rg, ol, oled")
extraOpenLibraryAuthorMapping = flag.String("Xa", "", "TSV file, mapping OL author keys (e.g. to plain text names")
@@ -78,7 +79,11 @@ func refToRelease(p []byte) ([]byte, error) {
err error
)
if err = json.Unmarshal(p, &ref); err != nil {
- return nil, err
+ if *bestEffort {
+ log.Printf("failed to unmarshal: %v", string(p))
+ } else {
+ return nil, err
+ }
}
if release, err = skate.RefToRelease(&ref); err != nil {
return nil, err
@@ -98,7 +103,11 @@ func rgSitemapToRelease(p []byte) ([]byte, error) {
err error
)
if err = json.Unmarshal(p, &s); err != nil {
- return nil, err
+ if *bestEffort {
+ log.Printf("failed to unmarshal: %v", string(p))
+ } else {
+ return nil, err
+ }
}
release.Title = s.Title
if len(s.URL) > 41 {
@@ -119,7 +128,11 @@ func openLibraryToRelease(p []byte) ([]byte, error) {
err error
)
if err = json.Unmarshal(p, &w); err != nil {
- return nil, err
+ if *bestEffort {
+ log.Printf("failed to unmarshal: %v", string(p))
+ } else {
+ return nil, err
+ }
}
if release, err = skate.OpenLibraryWorkToRelease(&w); err != nil {
return nil, err
@@ -137,7 +150,11 @@ func openLibraryEditionToRelease(p []byte) ([]byte, error) {
err error
)
if err = json.Unmarshal(p, &w); err != nil {
- return nil, err
+ if *bestEffort {
+ log.Printf("failed to unmarshal: %v", string(p))
+ } else {
+ return nil, err
+ }
}
if release, err = skate.OpenLibraryEditionToRelease(&w, openLibraryAuthorMap); err != nil {
return nil, err