summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-12-17 12:57:49 +0000
committerNick White <git@njw.name>2019-12-17 12:57:49 +0000
commit0de321abc7bb832db09b22f937f31d30e52f4365 (patch)
tree2f16948465ff72ac8bb98feba67e40f8b64d2197 /cmd
parent6c1947940fa6a8299d7ac0c880781ed40d3affe3 (diff)
Add png flag to getpipelinebook
Diffstat (limited to 'cmd')
-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() {