Compare commits

..

No commits in common. "c34a2557681b5201e478583649ee59ddf7544a78" and "45677c6b7b48624a0380901553eb2f6ac2908fc3" have entirely different histories.

18 changed files with 52 additions and 64 deletions

View File

@ -38,19 +38,19 @@ First ensure to have a working version of GO: [Installation](https://go.dev/doc/
Then install the last version of the tool: Then install the last version of the tool:
``` ```
$ go install github.com/celogeek/go-comic-converter/v3 $ go install github.com/celogeek/go-comic-converter/v2
``` ```
To force install a specific version: To force install a specific version:
``` ```
# specific version # specific version
$ go install github.com/celogeek/go-comic-converter/v3@v3.0.0 $ go install github.com/celogeek/go-comic-converter/v2@v2.6.9
# main branch # main branch
$ go install github.com/celogeek/go-comic-converter/v3@main $ go install github.com/celogeek/go-comic-converter/v2@main
# specific commit # specific commit
$ go install github.com/celogeek/go-comic-converter/v3@COMMIT_HASH $ go install github.com/celogeek/go-comic-converter/v2@141aeae
``` ```
Add GOPATH to your PATH Add GOPATH to your PATH
@ -58,27 +58,19 @@ Add GOPATH to your PATH
$ export PATH=$(go env GOPATH)/bin:$PATH $ export PATH=$(go env GOPATH)/bin:$PATH
``` ```
# Upgrade from V2
The configuration file structure changes in the v3 compare to v2.
You need to recreate your config and save it again.
Use the `show`, `reset` and `save` option.
# Check last version # Check last version
You can check if a new version is available with: You can check if a new version is available with:
``` ```
$ go-comic-converter -version $ go-comic-converter -version
go-comic-converter go-comic-converter
Path : github.com/celogeek/go-comic-converter/v3 Path : github.com/celogeek/go-comic-converter/v2
Sum : h1:tUFF2m/fGlOJOwC0/PlTopMfcBMprKvgr6TiQHQxEeo= Sum : h1:tUFF2m/fGlOJOwC0/PlTopMfcBMprKvgr6TiQHQxEeo=
Version : v3.0.0 Version : v2.6.9
Available Version: v3.0.0 Available Version: v2.6.9
To install the latest version: To install the latest version:
$ go install github.com/celogeek/go-comic-converter/v3@v3.0.0 $ go install github.com/celogeek/go-comic-converter/v2@v2.6.9
``` ```
# Supported image files # Supported image files

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/celogeek/go-comic-converter/v3 module github.com/celogeek/go-comic-converter/v2
go 1.23 go 1.23

View File

@ -18,7 +18,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type Converter struct { type Converter struct {

View File

@ -9,8 +9,8 @@ import (
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epuboptions"
"github.com/celogeek/go-comic-converter/v3/pkg/epuboptions" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type Options struct { type Options struct {

View File

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type Profile struct { type Profile struct {

View File

@ -14,21 +14,17 @@ import (
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubimage" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubimage"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubimageprocessor" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubimageprocessor"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubprogress" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epuboptions"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubtemplates" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubprogress"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubtree" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubtemplates"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubzip" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubtree"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubzip"
"github.com/celogeek/go-comic-converter/v3/pkg/epuboptions" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type EPUB interface { type EPUB struct {
Write() error
}
type epub struct {
epuboptions.EPUBOptions epuboptions.EPUBOptions
UID string UID string
Publisher string Publisher string
@ -52,7 +48,7 @@ func New(options epuboptions.EPUBOptions) EPUB {
"zoom": func(s int, z float32) int { return int(float32(s) * z) }, "zoom": func(s int, z float32) int { return int(float32(s) * z) },
}) })
return epub{ return EPUB{
EPUBOptions: options, EPUBOptions: options,
UID: uid.String(), UID: uid.String(),
Publisher: "GO Comic Converter", Publisher: "GO Comic Converter",
@ -63,7 +59,7 @@ func New(options epuboptions.EPUBOptions) EPUB {
} }
// render templates // render templates
func (e epub) render(templateString string, data map[string]any) string { func (e EPUB) render(templateString string, data map[string]any) string {
var result strings.Builder var result strings.Builder
tmpl := template.Must(e.templateProcessor.Parse(templateString)) tmpl := template.Must(e.templateProcessor.Parse(templateString))
if err := tmpl.Execute(&result, data); err != nil { if err := tmpl.Execute(&result, data); err != nil {
@ -73,7 +69,7 @@ func (e epub) render(templateString string, data map[string]any) string {
} }
// write image to the zip // write image to the zip
func (e epub) writeImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, zipImg *zip.File) error { func (e EPUB) writeImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, zipImg *zip.File) error {
err := wz.WriteContent( err := wz.WriteContent(
img.EPUBPagePath(), img.EPUBPagePath(),
[]byte(e.render(epubtemplates.Text, map[string]any{ []byte(e.render(epubtemplates.Text, map[string]any{
@ -91,7 +87,7 @@ func (e epub) writeImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, zipImg *zi
} }
// write blank page // write blank page
func (e epub) writeBlank(wz epubzip.EPUBZip, img epubimage.EPUBImage) error { func (e EPUB) writeBlank(wz epubzip.EPUBZip, img epubimage.EPUBImage) error {
return wz.WriteContent( return wz.WriteContent(
img.EPUBSpacePath(), img.EPUBSpacePath(),
[]byte(e.render(epubtemplates.Blank, map[string]any{ []byte(e.render(epubtemplates.Blank, map[string]any{
@ -102,7 +98,7 @@ func (e epub) writeBlank(wz epubzip.EPUBZip, img epubimage.EPUBImage) error {
} }
// write title image // write title image
func (e epub) writeCoverImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, part, totalParts int) error { func (e EPUB) writeCoverImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, part, totalParts int) error {
title := "Cover" title := "Cover"
text := "" text := ""
if totalParts > 1 { if totalParts > 1 {
@ -145,7 +141,7 @@ func (e epub) writeCoverImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, part,
} }
// write title image // write title image
func (e epub) writeTitleImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, title string) error { func (e EPUB) writeTitleImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, title string) error {
titleAlign := "" titleAlign := ""
if !e.Image.View.PortraitOnly { if !e.Image.View.PortraitOnly {
if e.Image.Manga { if e.Image.Manga {
@ -201,7 +197,7 @@ func (e epub) writeTitleImage(wz epubzip.EPUBZip, img epubimage.EPUBImage, title
} }
// extract image and split it into part // extract image and split it into part
func (e epub) getParts() (parts []epubPart, imgStorage epubzip.StorageImageReader, err error) { func (e EPUB) getParts() (parts []epubPart, imgStorage epubzip.StorageImageReader, err error) {
images, err := e.imageProcessor.Load() images, err := e.imageProcessor.Load()
if err != nil { if err != nil {
@ -272,7 +268,7 @@ func (e epub) getParts() (parts []epubPart, imgStorage epubzip.StorageImageReade
// create a tree from the directories. // create a tree from the directories.
// //
// this is used to simulate the toc. // this is used to simulate the toc.
func (e epub) getTree(images []epubimage.EPUBImage, skipFiles bool) string { func (e EPUB) getTree(images []epubimage.EPUBImage, skipFiles bool) string {
t := epubtree.New() t := epubtree.New()
for _, img := range images { for _, img := range images {
if skipFiles { if skipFiles {
@ -289,7 +285,7 @@ func (e epub) getTree(images []epubimage.EPUBImage, skipFiles bool) string {
return c.WriteString("") return c.WriteString("")
} }
func (e epub) computeAspectRatio(epubParts []epubPart) float64 { func (e EPUB) computeAspectRatio(epubParts []epubPart) float64 {
var ( var (
bestAspectRatio float64 bestAspectRatio float64
bestAspectRatioCount int bestAspectRatioCount int
@ -316,7 +312,7 @@ func (e epub) computeAspectRatio(epubParts []epubPart) float64 {
return bestAspectRatio return bestAspectRatio
} }
func (e epub) computeViewPort(epubParts []epubPart) (int, int) { func (e EPUB) computeViewPort(epubParts []epubPart) (int, int) {
if e.Image.View.AspectRatio == -1 { if e.Image.View.AspectRatio == -1 {
//keep device size //keep device size
return e.Image.View.Width, e.Image.View.Height return e.Image.View.Width, e.Image.View.Height
@ -336,7 +332,7 @@ func (e epub) computeViewPort(epubParts []epubPart) (int, int) {
} }
} }
func (e epub) writePart(path string, currentPart, totalParts int, part epubPart, imgStorage epubzip.StorageImageReader) error { func (e EPUB) writePart(path string, currentPart, totalParts int, part epubPart, imgStorage epubzip.StorageImageReader) error {
hasTitlePage := e.TitlePage == 1 || (e.TitlePage == 2 && totalParts > 1) hasTitlePage := e.TitlePage == 1 || (e.TitlePage == 2 && totalParts > 1)
wz, err := epubzip.New(path) wz, err := epubzip.New(path)
@ -417,7 +413,7 @@ func (e epub) writePart(path string, currentPart, totalParts int, part epubPart,
} }
// create the zip // create the zip
func (e epub) Write() error { func (e EPUB) Write() error {
epubParts, imgStorage, err := e.getParts() epubParts, imgStorage, err := e.getParts()
if err != nil { if err != nil {
return err return err

View File

@ -5,7 +5,7 @@ import (
"image" "image"
"strings" "strings"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type EPUBImage struct { type EPUBImage struct {

View File

@ -27,9 +27,9 @@ import (
pdfimage "github.com/raff/pdfreader/image" pdfimage "github.com/raff/pdfreader/image"
"github.com/raff/pdfreader/pdfread" "github.com/raff/pdfreader/pdfread"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/sortpath" "github.com/celogeek/go-comic-converter/v2/internal/pkg/sortpath"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type task struct { type task struct {

View File

@ -9,12 +9,12 @@ import (
"github.com/disintegration/gift" "github.com/disintegration/gift"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubimage" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubimage"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubimagefilters" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubimagefilters"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubprogress" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epuboptions"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubzip" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubprogress"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubzip"
"github.com/celogeek/go-comic-converter/v3/pkg/epuboptions" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type EPUBImageProcessor struct { type EPUBImageProcessor struct {

View File

@ -1,7 +1,7 @@
package epuboptions package epuboptions
import ( import (
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type View struct { type View struct {

View File

@ -9,7 +9,7 @@ import (
"github.com/schollz/progressbar/v3" "github.com/schollz/progressbar/v3"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type Options struct { type Options struct {

View File

@ -3,9 +3,9 @@ package epubtemplates
import ( import (
"github.com/beevik/etree" "github.com/beevik/etree"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubimage" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubimage"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epuboptions"
"github.com/celogeek/go-comic-converter/v3/pkg/epuboptions" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
type Content struct { type Content struct {

View File

@ -6,7 +6,7 @@ import (
"github.com/beevik/etree" "github.com/beevik/etree"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/epubimage" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epubimage"
) )
// Toc create toc // Toc create toc

View File

@ -14,9 +14,9 @@ import (
"github.com/tcnksm/go-latest" "github.com/tcnksm/go-latest"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/converter" "github.com/celogeek/go-comic-converter/v2/internal/pkg/converter"
"github.com/celogeek/go-comic-converter/v3/internal/pkg/utils" "github.com/celogeek/go-comic-converter/v2/internal/pkg/epub"
"github.com/celogeek/go-comic-converter/v3/pkg/epub" "github.com/celogeek/go-comic-converter/v2/internal/pkg/utils"
) )
func main() { func main() {