diff options
author | Nick White <git@njw.name> | 2019-12-05 17:59:02 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2019-12-05 17:59:02 +0000 |
commit | 2318b478fc2769ca09590006d8483463ae763b22 (patch) | |
tree | 459706d1e357cb7a3e4167dbf78fc34653183fc5 | |
parent | 74fb901e360cb3b5605485c07cd366c316309d1a (diff) |
Default getpipelinebook to downloading pdfs instead of images
-rw-r--r-- | cmd/getpipelinebook/main.go | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/cmd/getpipelinebook/main.go b/cmd/getpipelinebook/main.go index d7d3e41..faf5383 100644 --- a/cmd/getpipelinebook/main.go +++ b/cmd/getpipelinebook/main.go @@ -7,7 +7,6 @@ import ( "log" "os" "path/filepath" - "strings" "rescribe.xyz/bookpipeline" ) @@ -41,7 +40,6 @@ type Pipeliner interface { func main() { all := flag.Bool("a", false, "Get all files for book") - colour := flag.Bool("c", false, "Also get the original page images") verbose := flag.Bool("v", false, "Verbose") flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), usage) @@ -107,7 +105,7 @@ func main() { } defer f.Close() - verboselog.Println("Downloading HOCR and corresponding image files") + verboselog.Println("Downloading HOCR files") s := bufio.NewScanner(f) for s.Scan() { fn = filepath.Join(bookname, s.Text()) @@ -116,32 +114,20 @@ func main() { if err != nil { log.Fatalln("Failed to download file", fn, err) } - b := strings.TrimSuffix(s.Text(), ".hocr") - fn = filepath.Join(bookname, b + ".png") - verboselog.Println("Downloading file", fn) - err = conn.Download(conn.WIPStorageId(), fn, fn) - if err != nil { - log.Fatalln("Failed to download file", fn, err) - } - if *colour { - parts := strings.SplitN(s.Text(), "_bin", 2) - if len(parts) < 2 { - verboselog.Println("Can't find page number for original page image, skipping", b) - continue - } - num := parts[0] - fn = filepath.Join(bookname, num + ".jpg") - verboselog.Println("Downloading file", fn) - err = conn.Download(conn.WIPStorageId(), fn, fn) - if err != nil { - fn = filepath.Join(bookname, num + ".png") - verboselog.Println("Downloading file", fn) - err = conn.Download(conn.WIPStorageId(), fn, fn) - if err != nil { - log.Fatalln("Failed to download file", fn, err) - } - } - } + } + + verboselog.Println("Downloading PDF files") + fn = filepath.Join(bookname, bookname + ".colour.pdf") + verboselog.Println("Downloading file", fn) + err = conn.Download(conn.WIPStorageId(), fn, fn) + if err != nil { + log.Println("Failed to download %s: %s", fn, err) + } + fn = filepath.Join(bookname, bookname + ".binarised.pdf") + verboselog.Println("Downloading file", fn) + err = conn.Download(conn.WIPStorageId(), fn, fn) + if err != nil { + log.Println("Failed to download %s: %s", fn, err) } analyses := []string{"conf", "graph.png"} |