audiobooker

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Aac  = ".aac"
	Flac = ".flac"
	Mp4  = ".mp4"
	M4a  = ".m4a"
	M4b  = ".m4b"
	Mp3  = ".mp3"
	Ogg  = ".ogg"
	Opus = ".opus"
)
View Source
const (
	AudioFile   = "%f"
	Author      = "%a"
	Genre       = "%g"
	Narrator    = "%n"
	ReleaseDate = "%y"
	Series      = "%s"
	SeriesPart  = "%p"
	Title       = "%t"
)

path templates

View Source
const (
	AuthorGrok      = "%{GREEDYDATA:author}"
	AudioFileGrok   = "%{AUDIO_FILE:audio_file}"
	GenreGrok       = "%{GREEDYDATA:genre}"
	NarratorGrok    = "%{GREEDYDATA:narrator}"
	ReleaseDateGrok = "%{NUMBER:release_date}"
	SeriesGrok      = "%{GREEDYDATA:series}"
	SeriesPartGrok  = "%{NUMBER:series_part}"
	TitleGrok       = "%{GREEDYDATA:title}"
)

pattern Groks

Variables

This section is empty.

Functions

func Bind

func Bind(config Config, book Book) error

Bind apply metadata and output m4b file

func Combine

func Combine(config Config) error

Combine transcode and combines source files into m4a file

func OutputFilePattern

func OutputFilePattern(book Book, pathPattern string) string

OutputFilePattern renders filename based on path pattern and Book data

func OutputPathPattern

func OutputPathPattern(book Book, pathPattern string) (string, error)

OutputPathPattern renders directory structure based on path pattern and Book data

func ParsePathTags

func ParsePathTags(path, pathPattern string) (map[string]string, error)

ParsePathTags takes in file path and pattern string returning a map of the pattern matched values

func SplitSingleFile

func SplitSingleFile(config *Config) error

SplitSingleFile splits single file into chunks for later transcoding

func TranscodeSourceFiles

func TranscodeSourceFiles(config *Config) error

TranscodeSourceFiles runs concurrent transcode of source media into mp4 audio files for combination later

Types

type Book

type Book struct {
	Author      string
	Chapters    []*Chapter
	Date        *string
	Description *string
	Genre       *string
	Narrator    *string
	SortSlug    *string
	Title       string
	// contains filtered or unexported fields
}

Book top level construct of book

func (*Book) CalcChapterTimes

func (b *Book) CalcChapterTimes()

CalcChapterTimes calculates the duration of the chapter

func (*Book) ChapterByFile

func (b *Book) ChapterByFile(config Config, useFileNames, useTagTitle bool) error

ChapterByFile creates Chapter objects from individual files

func (*Book) ExtractChapters

func (b *Book) ExtractChapters(config Config) error

ExtractChapters creates file from embedded chapters

func (*Book) GenerateMetaTemplate

func (b *Book) GenerateMetaTemplate(config Config) error

GenerateMetaTemplate writes out the compiled metadata template for use when compiling to m4b

func (*Book) GenerateStaticChapters

func (b *Book) GenerateStaticChapters(config Config, chapterLengthMin int) error

GenerateStaticChapters creates Chapter objects based on specified length

func (*Book) ParseFromPattern

func (b *Book) ParseFromPattern(tags map[string]string)

ParseFromPattern parses map of tags generated from path into attributes

func (*Book) ParseToChapters

func (b *Book) ParseToChapters(config Config) error

ParseToChapters creates Chapter objects out of tagged files

func (*Book) WriteTags

func (b *Book) WriteTags(filename string) error

WriteTags overrides global metadata with data from Book

type Chapter

type Chapter struct {
	LengthMs int64
	StartMs  int64
	EndMs    int64
	Number   int
	Title    string
	Tracks   []TrackFile
}

Chapter holds data for each chapter construct

func (*Chapter) Compile

func (c *Chapter) Compile()

Compile compiles Chapter length based off the collection of tracks associated to the chapter

func (*Chapter) StampTimes

func (c *Chapter) StampTimes(startTime int64) int64

StampTimes compiles the start and end time for each chapter

type Config

type Config struct {
	// ChaptersFile file handler for chapters file
	ChaptersFile *os.File
	// DescriptionFilename optional filename for book description data
	DescriptionFilename string
	// ExternalChapters pull chapters from existing file
	ExternalChapters bool
	// Jobs number of concurrent transcode jobs to run
	Jobs int `yaml:"jobs" env:"JOBS"`
	// OutputFileDest path to output file TODO allow for custom file name
	OutputFileDest string `yaml:"output_file_dest" env:"OUTPUT_FILE_DEST"`
	// OutputFilePattern placeholder for output filename template
	OutputFilePattern string `yaml:"output_file_pattern" env:"OUTPUT_FILE_PATTERN"`
	// OutputPathPattern placeholder for output path template
	OutputPathPattern string `yaml:"output_path_pattern" env:"OUTPUT_PATH_PATTERN"`
	// PathPattern placeholder template string
	PathPattern string `yaml:"path_pattern" env:"PATH_PATTERN"`
	// ScratchFilesPath path to put scratch files
	ScratchFilesPath string `yaml:"scratch_files_path" env:"SCRATCH_FILES_PATH"`
	// SourceFilesPath wildcard glob of files to use as input TODO refine this into options
	SourceFilesPath string
	// TracksFile file handler for tracks to transcode/compile file
	TracksFile *os.File
	// VerboseTranscode show verbose output of ffmpeg commands
	VerboseTranscode bool

	// OutputFile filename of final book output file
	OutputFile string
	// OutputPath rendered path directories
	OutputPath string
	// contains filtered or unexported fields
}

Config application config data

func ParseConfig

func ParseConfig(filename string) (Config, error)

ParseConfig returns a config struct from a config file

func (*Config) Cleanup

func (c *Config) Cleanup() error

Cleanup removes temporary scratch files

func (*Config) New

func (c *Config) New() error

New provisions new Config object

func (*Config) Parse

func (c *Config) Parse() error

Parse sets defaults of parsed env/config file variables

func (*Config) SetOutputFilename

func (c *Config) SetOutputFilename(book Book) error

SetOutputFilename sets the output filename based on metadata

type TrackFile

type TrackFile struct {
	LengthMs int64
	File     *os.File
}

TrackFile handles individual data and operations for files

func (*TrackFile) Parse

func (t *TrackFile) Parse(filename string) error

Parse loads the metadata from file including the file name and length

Jump to

Keyboard shortcuts

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