mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
move epuboptions outside epub
This commit is contained in:
parent
74076507f0
commit
55b8bbe6b3
4
main.go
4
main.go
@ -15,7 +15,7 @@ import (
|
||||
|
||||
"github.com/celogeek/go-comic-converter/v2/internal/converter"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epub"
|
||||
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epuboptions"
|
||||
"github.com/tcnksm/go-latest"
|
||||
)
|
||||
|
||||
@ -107,7 +107,7 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
||||
|
||||
profile := cmd.Options.GetProfile()
|
||||
|
||||
if err := epub.New(&epuboptions.Options{
|
||||
if err := epub.New(&epuboptions.EPUBOptions{
|
||||
Input: cmd.Options.Input,
|
||||
Output: cmd.Options.Output,
|
||||
LimitMb: cmd.Options.LimitMb,
|
||||
|
@ -17,8 +17,8 @@ import (
|
||||
|
||||
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
||||
epubimageprocessor "github.com/celogeek/go-comic-converter/v2/pkg/epub/imageprocessor"
|
||||
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
||||
epubtemplates "github.com/celogeek/go-comic-converter/v2/pkg/epub/templates"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epuboptions"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epubprogress"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epubtree"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epubzip"
|
||||
@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
type ePub struct {
|
||||
*epuboptions.Options
|
||||
*epuboptions.EPUBOptions
|
||||
UID string
|
||||
Publisher string
|
||||
UpdatedAt string
|
||||
@ -42,7 +42,7 @@ type epubPart struct {
|
||||
}
|
||||
|
||||
// initialize EPUB
|
||||
func New(options *epuboptions.Options) *ePub {
|
||||
func New(options *epuboptions.EPUBOptions) *ePub {
|
||||
uid := uuid.Must(uuid.NewV4())
|
||||
tmpl := template.New("parser")
|
||||
tmpl.Funcs(template.FuncMap{
|
||||
@ -51,7 +51,7 @@ func New(options *epuboptions.Options) *ePub {
|
||||
})
|
||||
|
||||
return &ePub{
|
||||
Options: options,
|
||||
EPUBOptions: options,
|
||||
UID: uid.String(),
|
||||
Publisher: "GO Comic Converter",
|
||||
UpdatedAt: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
|
||||
|
@ -13,17 +13,17 @@ import (
|
||||
|
||||
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
||||
epubimagefilters "github.com/celogeek/go-comic-converter/v2/pkg/epub/imagefilters"
|
||||
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epuboptions"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epubprogress"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epubzip"
|
||||
"github.com/disintegration/gift"
|
||||
)
|
||||
|
||||
type EPUBImageProcessor struct {
|
||||
*epuboptions.Options
|
||||
*epuboptions.EPUBOptions
|
||||
}
|
||||
|
||||
func New(o *epuboptions.Options) *EPUBImageProcessor {
|
||||
func New(o *epuboptions.EPUBOptions) *EPUBImageProcessor {
|
||||
return &EPUBImageProcessor{o}
|
||||
}
|
||||
|
||||
@ -105,8 +105,8 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
|
||||
// do not keep double page if requested
|
||||
if !img.IsCover &&
|
||||
img.DoublePage &&
|
||||
e.Options.Image.AutoSplitDoublePage &&
|
||||
!e.Options.Image.KeepDoublePageIfSplitted {
|
||||
e.EPUBOptions.Image.AutoSplitDoublePage &&
|
||||
!e.EPUBOptions.Image.KeepDoublePageIfSplitted {
|
||||
continue
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ func (e *EPUBImageProcessor) Load() (images []*epubimage.Image, err error) {
|
||||
}
|
||||
|
||||
func (e *EPUBImageProcessor) createImage(src image.Image, r image.Rectangle) draw.Image {
|
||||
if e.Options.Image.GrayScale {
|
||||
if e.EPUBOptions.Image.GrayScale {
|
||||
return image.NewGray(r)
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/beevik/etree"
|
||||
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
||||
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
||||
"github.com/celogeek/go-comic-converter/v2/pkg/epuboptions"
|
||||
)
|
||||
|
||||
type ContentOptions struct {
|
||||
|
@ -41,7 +41,7 @@ type Image struct {
|
||||
AppleBookCompatibility bool
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
type EPUBOptions struct {
|
||||
Input string
|
||||
Output string
|
||||
Title string
|
||||
@ -58,7 +58,7 @@ type Options struct {
|
||||
Image *Image
|
||||
}
|
||||
|
||||
func (o *Options) WorkersRatio(pct int) (nbWorkers int) {
|
||||
func (o *EPUBOptions) WorkersRatio(pct int) (nbWorkers int) {
|
||||
nbWorkers = o.Workers * pct / 100
|
||||
if nbWorkers < 1 {
|
||||
nbWorkers = 1
|
||||
@ -66,6 +66,6 @@ func (o *Options) WorkersRatio(pct int) (nbWorkers int) {
|
||||
return
|
||||
}
|
||||
|
||||
func (o *Options) ImgStorage() string {
|
||||
func (o *EPUBOptions) ImgStorage() string {
|
||||
return fmt.Sprintf("%s.tmp", o.Output)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user