mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
remove plural from tasks
This commit is contained in:
parent
51f62588c2
commit
56943aa96c
@ -28,7 +28,7 @@ import (
|
|||||||
"github.com/raff/pdfreader/pdfread"
|
"github.com/raff/pdfreader/pdfread"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tasks struct {
|
type task struct {
|
||||||
Id int
|
Id int
|
||||||
Image image.Image
|
Image image.Image
|
||||||
Path string
|
Path string
|
||||||
@ -50,7 +50,7 @@ func (e *EPUBImageProcessor) isSupportedImage(path string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load images from input
|
// Load images from input
|
||||||
func (e *EPUBImageProcessor) load() (totalImages int, output chan *tasks, err error) {
|
func (e *EPUBImageProcessor) load() (totalImages int, output chan *task, err error) {
|
||||||
fi, err := os.Stat(e.Input)
|
fi, err := os.Stat(e.Input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -98,7 +98,7 @@ func (e *EPUBImageProcessor) corruptedImage(path, name string) image.Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load a directory of images
|
// load a directory of images
|
||||||
func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *tasks, err error) {
|
func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *task, err error) {
|
||||||
images := make([]string, 0)
|
images := make([]string, 0)
|
||||||
|
|
||||||
input := filepath.Clean(e.Input)
|
input := filepath.Clean(e.Input)
|
||||||
@ -139,7 +139,7 @@ func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *tasks, err
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// read in parallel and get an image
|
// read in parallel and get an image
|
||||||
output = make(chan *tasks, e.Workers)
|
output = make(chan *task, e.Workers)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
for j := 0; j < e.WorkersRatio(50); j++ {
|
for j := 0; j < e.WorkersRatio(50); j++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -166,7 +166,7 @@ func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *tasks, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
img = e.corruptedImage(p, fn)
|
img = e.corruptedImage(p, fn)
|
||||||
}
|
}
|
||||||
output <- &tasks{
|
output <- &task{
|
||||||
Id: job.Id,
|
Id: job.Id,
|
||||||
Image: img,
|
Image: img,
|
||||||
Path: p,
|
Path: p,
|
||||||
@ -187,7 +187,7 @@ func (e *EPUBImageProcessor) loadDir() (totalImages int, output chan *tasks, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load a zip file that include images
|
// load a zip file that include images
|
||||||
func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *tasks, err error) {
|
func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *task, err error) {
|
||||||
r, err := zip.OpenReader(e.Input)
|
r, err := zip.OpenReader(e.Input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -231,7 +231,7 @@ func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *tasks, err
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
output = make(chan *tasks, e.Workers)
|
output = make(chan *task, e.Workers)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
for j := 0; j < e.WorkersRatio(50); j++ {
|
for j := 0; j < e.WorkersRatio(50); j++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -253,7 +253,7 @@ func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *tasks, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
img = e.corruptedImage(p, fn)
|
img = e.corruptedImage(p, fn)
|
||||||
}
|
}
|
||||||
output <- &tasks{
|
output <- &task{
|
||||||
Id: job.Id,
|
Id: job.Id,
|
||||||
Image: img,
|
Image: img,
|
||||||
Path: p,
|
Path: p,
|
||||||
@ -273,7 +273,7 @@ func (e *EPUBImageProcessor) loadCbz() (totalImages int, output chan *tasks, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load a rar file that include images
|
// load a rar file that include images
|
||||||
func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *tasks, err error) {
|
func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *task, err error) {
|
||||||
var isSolid bool
|
var isSolid bool
|
||||||
files, err := rardecode.List(e.Input)
|
files, err := rardecode.List(e.Input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -350,7 +350,7 @@ func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *tasks, err
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// send file to the queue
|
// send file to the queue
|
||||||
output = make(chan *tasks, e.Workers)
|
output = make(chan *task, e.Workers)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
for j := 0; j < e.WorkersRatio(50); j++ {
|
for j := 0; j < e.WorkersRatio(50); j++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -372,7 +372,7 @@ func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *tasks, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
img = e.corruptedImage(p, fn)
|
img = e.corruptedImage(p, fn)
|
||||||
}
|
}
|
||||||
output <- &tasks{
|
output <- &task{
|
||||||
Id: job.Id,
|
Id: job.Id,
|
||||||
Image: img,
|
Image: img,
|
||||||
Path: p,
|
Path: p,
|
||||||
@ -390,7 +390,7 @@ func (e *EPUBImageProcessor) loadCbr() (totalImages int, output chan *tasks, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// extract image from a pdf
|
// extract image from a pdf
|
||||||
func (e *EPUBImageProcessor) loadPdf() (totalImages int, output chan *tasks, err error) {
|
func (e *EPUBImageProcessor) loadPdf() (totalImages int, output chan *task, err error) {
|
||||||
pdf := pdfread.Load(e.Input)
|
pdf := pdfread.Load(e.Input)
|
||||||
if pdf == nil {
|
if pdf == nil {
|
||||||
err = fmt.Errorf("can't read pdf")
|
err = fmt.Errorf("can't read pdf")
|
||||||
@ -399,7 +399,7 @@ func (e *EPUBImageProcessor) loadPdf() (totalImages int, output chan *tasks, err
|
|||||||
|
|
||||||
totalImages = len(pdf.Pages())
|
totalImages = len(pdf.Pages())
|
||||||
pageFmt := fmt.Sprintf("page %%0%dd", len(fmt.Sprintf("%d", totalImages)))
|
pageFmt := fmt.Sprintf("page %%0%dd", len(fmt.Sprintf("%d", totalImages)))
|
||||||
output = make(chan *tasks)
|
output = make(chan *task)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(output)
|
defer close(output)
|
||||||
defer pdf.Close()
|
defer pdf.Close()
|
||||||
@ -414,7 +414,7 @@ func (e *EPUBImageProcessor) loadPdf() (totalImages int, output chan *tasks, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
img = e.corruptedImage("", name)
|
img = e.corruptedImage("", name)
|
||||||
}
|
}
|
||||||
output <- &tasks{
|
output <- &task{
|
||||||
Id: i,
|
Id: i,
|
||||||
Image: img,
|
Image: img,
|
||||||
Path: "",
|
Path: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user