summaryrefslogtreecommitdiff
path: root/cmd/getpipelinebook/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/getpipelinebook/main.go')
-rw-r--r--cmd/getpipelinebook/main.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/getpipelinebook/main.go b/cmd/getpipelinebook/main.go
index 5bb2e28..fdfd307 100644
--- a/cmd/getpipelinebook/main.go
+++ b/cmd/getpipelinebook/main.go
@@ -7,11 +7,12 @@ import (
"log"
"os"
"path/filepath"
+ "strings"
"rescribe.xyz/bookpipeline"
)
-const usage = `Usage: getpipelinebook [-a] [-pdf] [-v] bookname
+const usage = `Usage: getpipelinebook [-a] [-pdf] [-png] [-v] bookname
Downloads the pipeline results for a book.
@@ -52,6 +53,7 @@ func getpdfs(conn Pipeliner, l *log.Logger, bookname string) {
func main() {
all := flag.Bool("a", false, "Get all files for book")
pdf := flag.Bool("pdf", false, "Only download PDFs")
+ png := flag.Bool("png", false, "Only download best binarised png files")
verbose := flag.Bool("v", false, "Verbose")
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), usage)
@@ -122,6 +124,21 @@ func main() {
}
defer f.Close()
+ if *png {
+ verboselog.Println("Downloading png files")
+ s := bufio.NewScanner(f)
+ for s.Scan() {
+ txtfn := filepath.Join(bookname, s.Text())
+ fn = strings.Replace(txtfn, ".hocr", ".png", 1)
+ verboselog.Println("Downloading file", fn)
+ err = conn.Download(conn.WIPStorageId(), fn, fn)
+ if err != nil {
+ log.Fatalln("Failed to download file", fn, err)
+ }
+ }
+ return
+ }
+
verboselog.Println("Downloading HOCR files")
s := bufio.NewScanner(f)
for s.Scan() {