diff options
author | Nick White <git@njw.name> | 2022-02-23 12:56:36 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2022-02-23 12:56:36 +0000 |
commit | a4d9ca8671292f9028db51748f4f028746d9bdef (patch) | |
tree | 56f3bc34ea6cc7ca2a48f50e25c0ae8b736c0e1f /cmd/rescribe/main.go | |
parent | 2c29e91bd98a1354d0cc4772ca629e3f1fc327b5 (diff) |
rescribe: Add embedded support for getgbook, for linux only so far
Diffstat (limited to 'cmd/rescribe/main.go')
-rw-r--r-- | cmd/rescribe/main.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/cmd/rescribe/main.go b/cmd/rescribe/main.go index 7db5e3e..65ecd60 100644 --- a/cmd/rescribe/main.go +++ b/cmd/rescribe/main.go @@ -201,6 +201,20 @@ These training files are included in rescribe, and are always available: } } + err = unpackZip(gbookzip, tessdir) + if err != nil { + log.Fatalln("Error unpacking embedded getgbook zip:", err) + } + var gbookCommand string + switch runtime.GOOS { + case "darwin": + tessCommand = filepath.Join(tessdir, "getgbook") + case "linux": + gbookCommand = filepath.Join(tessdir, "getgbook") + case "windows": + tessCommand = filepath.Join(tessdir, "getgbook.exe") + } + tessdatadir := filepath.Join(tessdir, "tessdata") err = os.MkdirAll(tessdatadir, 0755) if err != nil { @@ -238,7 +252,7 @@ These training files are included in rescribe, and are always available: } if flag.NArg() < 1 || *usegui { - err := startGui(*verboselog, tessCommand, trainingName, tessdir) + err := startGui(*verboselog, tessCommand, gbookCommand, trainingName, tessdir) err = os.RemoveAll(tessdir) if err != nil { log.Printf("Error removing tesseract directory %s: %v", tessdir, err) @@ -266,12 +280,16 @@ These training files are included in rescribe, and are always available: var ctx context.Context + // TODO: support google book downloading, as done with the GUI + // try opening as a PDF, and extracting if !fi.IsDir() { if flag.NArg() < 2 { savedir = strings.TrimSuffix(bookdir, ".pdf") } + // BUG: this seems to fail from command line, yet works from GUI + // (used to work) bookdir, err = extractPdfImgs(ctx, bookdir) if err != nil { log.Fatalln("Error opening file as PDF:", err) |