logic

package
v0.0.0-...-aaed588 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2023 License: Unlicense Imports: 19 Imported by: 0

Documentation

Overview

Package logic contains the logic used on manga-toolkit clients

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPage

func AddPage(pdf fpdf.Pdf, imgType string, buffer *bytes.Buffer)

AddPage adds the manga image page buffer as a page to the PDF

func EncodePage

func EncodePage(image Page, buffer *bytes.Buffer) error

EncodePage encode a manga image page into the provided buffer If the page is on landscape mode it'll be rotated -90 degrees and will became portrait mode

func GenerateOutput

func GenerateOutput(chapter Chapter, output io.WriteCloser) error

func GetImageFormat

func GetImageFormat(image Page) (string, error)

GetImageFormat extracts the image format from the manga image page

func IsValidExtension

func IsValidExtension(ext string) bool

IsValidExtension check if the image has a valid extension

Types

type Chapter

type Chapter struct {
	Pages []Page
}

func NewChapter

func NewChapter(ctx context.Context, reader *zip.ReadCloser) (Chapter, error)

NewChapter iterate through the ZIP file, open the content and return a list of images. Remember to close the images after using it!

func (Chapter) ForeachPage

func (c Chapter) ForeachPage(do func(page Page) error) error

func (Chapter) SortPages

func (c Chapter) SortPages()

type Logic

type Logic interface {
	GeneratePDFFromZip(ctx context.Context, reader *zip.ReadCloser, output io.WriteCloser) error
	DownloadChapters(ctx context.Context, mangaTerm string, outputDir string, fromChapter int, toChapter int) error
}

Logic abstracts the logic used on manga-toolkit

func NewLogic

func NewLogic(mangaFreakService services.MangaFreakService) Logic

NewLogic builds the logic used on manga-toolkit

type Page

type Page struct {
	Content    io.ReadCloser
	FileInfo   fs.FileInfo
	PageNumber int
}

Page represents a manga image page

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL