From 0de321abc7bb832db09b22f937f31d30e52f4365 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 17 Dec 2019 12:57:49 +0000 Subject: Add png flag to getpipelinebook --- cmd/getpipelinebook/main.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'cmd/getpipelinebook') 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() { -- cgit v1.2.1-24-ge1ad