diff --git a/main.go b/main.go index db7deda..8c17132 100644 --- a/main.go +++ b/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, diff --git a/pkg/epub/epub.go b/pkg/epub/epub.go index 010c6fd..cea3169 100644 --- a/pkg/epub/epub.go +++ b/pkg/epub/epub.go @@ -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"), diff --git a/pkg/epub/imageprocessor/imageprocessor.go b/pkg/epub/imageprocessor/imageprocessor.go index 71b22aa..3e0c86e 100644 --- a/pkg/epub/imageprocessor/imageprocessor.go +++ b/pkg/epub/imageprocessor/imageprocessor.go @@ -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) } diff --git a/pkg/epub/templates/epub_templates_content.go b/pkg/epub/templates/epub_templates_content.go index c4ea5e8..10d9938 100644 --- a/pkg/epub/templates/epub_templates_content.go +++ b/pkg/epub/templates/epub_templates_content.go @@ -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 { diff --git a/pkg/epub/options/options.go b/pkg/epuboptions/epuboptions.go similarity index 91% rename from pkg/epub/options/options.go rename to pkg/epuboptions/epuboptions.go index 2de0277..f6d432c 100644 --- a/pkg/epub/options/options.go +++ b/pkg/epuboptions/epuboptions.go @@ -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) }