Documentation
¶
Index ¶
- Constants
- func NewFilenameFromTemplate(templ string, parts FilenameTemplateParts) (string, error)
- func PackBundle(outputDir string, s grabber.Site, chapters []*DownloadedChapter, rng string, ...) (string, error)
- func PackSingle(outputDir string, s grabber.Site, chapter *DownloadedChapter, ...) (string, error)
- func SanitizeFilename(filename string) string
- type Archiver
- type CBZArchiver
- type DownloadedChapter
- type EPUBArchiver
- type FilenameTemplateParts
- type RAWArchiver
- type ZIPArchiver
Constants ¶
const FilenameTemplateDefault = "{{.Series}} {{.Number}} - {{.Title}}"
FilenameTemplateDefault is the default filename template
Variables ¶
This section is empty.
Functions ¶
func NewFilenameFromTemplate ¶
func NewFilenameFromTemplate(templ string, parts FilenameTemplateParts) (string, error)
NewFilenameFromTemplate returns a new filename from a series title, a chapter and a template
func PackBundle ¶
func PackBundle( outputDir string, s grabber.Site, chapters []*DownloadedChapter, rng string, progress func(page, total int), ) (string, error)
PackBundle packages multiple chapters into one archive or raw-folder bundle.
func PackSingle ¶
func PackSingle( outputDir string, s grabber.Site, chapter *DownloadedChapter, progress func(page, total int), ) (string, error)
PackSingle packages one chapter. If format=="raw" it creates a folder; otherwise it creates a .cbz/.zip via the archiver.
func SanitizeFilename ¶
SanitizeFilename sanitizes a filename
Types ¶
type Archiver ¶
type Archiver interface { // Archive packages the given files into an archive (or folder) at outputDir // using the provided base filename. It reports progress via the callback. // It returns the full path to the created archive. Archive(outputDir, filename string, files []*downloader.File, progress func(page, progress int)) (string, error) // Extension returns the file extension (without the dot) for this archive type. Extension() string }
Archiver defines the interface for packaging downloaded files.
func NewArchiver ¶
NewArchiver returns an Archiver implementation based on the provided format. Supported formats are: "cbz", "zip", and "raw".
type CBZArchiver ¶
type CBZArchiver struct{}
CBZArchiver creates a CBZ archive (.cbz file) from a set of images.
func (*CBZArchiver) Archive ¶
func (a *CBZArchiver) Archive(outputDir, filename string, files []*downloader.File, progress func(page, progress int)) (string, error)
Archive creates a CBZ file by zipping all provided image files. Each file is named with a three-digit counter (e.g. "001.jpg").
func (*CBZArchiver) Extension ¶
func (a *CBZArchiver) Extension() string
Extension returns the CBZ file extension.
type DownloadedChapter ¶
type DownloadedChapter struct { *grabber.Chapter Files []*downloader.File }
DownloadedChapter represents a downloaded chapter (info + files).
type EPUBArchiver ¶
type EPUBArchiver struct{}
EPUBArchiver converts a chapter into an EPUB file. It first creates a temporary CBZ archive (using CBZArchiver from packer/cbz.go) then calls the external "go-comic-converter" tool to produce an EPUB. Ensure that "go-comic-converter" is installed and available in your PATH.
func (*EPUBArchiver) Archive ¶
func (a *EPUBArchiver) Archive(outputDir, filename string, files []*downloader.File, progress func(page, progress int)) (string, error)
Archive creates a temporary CBZ archive from the provided files and then converts that archive into an EPUB using go-comic-converter. The output EPUB is saved at outputDir with the given filename.
func (*EPUBArchiver) Extension ¶
func (a *EPUBArchiver) Extension() string
Extension returns the EPUB file extension.
type FilenameTemplateParts ¶
type FilenameTemplateParts struct { // Series represents the series name (e.g. "One Piece") Series string // Number represents the chapter number (e.g. "1.0") Number string // Title represents the chapter title (e.g. "The Beginning") Title string }
FilenameTemplateParts represents the parts of a filename
func NewChapterFileTemplateParts ¶
func NewChapterFileTemplateParts(title string, chapter *grabber.Chapter) FilenameTemplateParts
NewChapterFileTemplateParts returns a new FilenameTemplateParts from a title and a chapter
type RAWArchiver ¶
type RAWArchiver struct{}
RAWArchiver simply writes each image file to a folder without archiving.
func (*RAWArchiver) Archive ¶
func (a *RAWArchiver) Archive(outputDir, filename string, files []*downloader.File, progress func(page, progress int)) (string, error)
Archive exports each image to a directory named with the given filename plus a "_raw" suffix.
func (*RAWArchiver) Extension ¶
func (a *RAWArchiver) Extension() string
Extension returns a pseudo extension for raw export.
type ZIPArchiver ¶
type ZIPArchiver struct{}
ZIPArchiver is functionally similar to CBZArchiver but uses a .zip extension.
func (*ZIPArchiver) Archive ¶
func (a *ZIPArchiver) Archive(outputDir, filename string, files []*downloader.File, progress func(page, progress int)) (string, error)
Archive creates a ZIP archive (.zip file) with the provided images.
func (*ZIPArchiver) Extension ¶
func (a *ZIPArchiver) Extension() string
Extension returns the ZIP file extension.