tpb

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 15 Imported by: 1

README

tpb

Build Status
a tool that uses YAML/Go templates to zip and name CBZ (comic book) archives

what it can do

  • int-indexed comics (date-indexed are WIP)

usage

cli
  • go install git.gryffyn.io/gryffyn/tpb/cmd/tpb@latest
  • copy contrib/tpb.yml.dist somewhere
  • edit the file to fit your comic
  • run tpb -h
  • most likely you'll wanna do something like tpb -Dod out/ *.jpg
  • or more likely fd -t f -e png -e jpg -e jpg -e gif -e txt | xargs tpb -Dod out/ *.jpg
lib

pretty much gotta do this:

package main

import (
    "git.gryffyn.io/gryffyn/tpb"
)

func main() {
    var files []string // list of files
    
    t := tpb.TPB {
        OutDir: "out/",
    }
    
    t.ReadConfigFile("tpb.yml")
    t.Collect(files)
}

why tpb

cause it's like trade paperback, which is a collection of comic strips. it's a joke. or meant to be.

get it?

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OutputTemplate = `{{- .Comic }} {{ .FmtID "%03d" -}}{{ with .Year }} ({{ . }}){{ end -}}{{ with .Title }} - {{ . }}){{ end -}}.cbz`
)

Functions

func MapFiles

func MapFiles(files *[]string) (map[int][]string, error)

MapFiles takes a slice of file names nad creates a mapping from the numerical order of the strip to the filename. If an error occurs, MapFiles returns a partially-full map and the error.

func ZipFiles

func ZipFiles(files *[]string, filename string, delete bool, bar *mpb.Bar) error

ZipFiles zips the given files to the given filename, optionally deleting the files once zipped.

Types

type Config

type Config struct {
	Format *string `yaml:"format,omitempty"`
	Comic  struct {
		Name     string `yaml:"name"`
		Sections []struct {
			Start *int    `yaml:"start,omitempty"`
			End   int     `yaml:"end"`
			Year  *int    `yaml:"year,omitempty"`
			Title *string `yaml:"title,omitempty"`
		} `yaml:"sections"`
	} `yaml:"comic,omitempty"`
}

func (*Config) Parse

func (c *Config) Parse(data []byte) error

type SecData

type SecData struct {
	ID    int
	Comic string
	Title string
	Year  int
}

func (SecData) FmtID

func (s SecData) FmtID(format string) string

type TPB

type TPB struct {
	OutDir    *string
	Overwrite bool
	Delete    bool
	Config    Config
}

func (*TPB) Collect

func (t *TPB) Collect(fs []string) error

Collect tales in a list of files and archives them according to the Config and the OutputTemplate.

func (*TPB) ReadConfigBytes

func (t *TPB) ReadConfigBytes(config []byte) error

ReadConfigBytes reads a Config from the given byte slice.

func (*TPB) ReadConfigFile

func (t *TPB) ReadConfigFile(file *os.File) error

ReadConfigFile reads a Config from the given file.

Directories

Path Synopsis
cmd
tpb Module

Jump to

Keyboard shortcuts

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