template

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeFilename

func SanitizeFilename(s string) string

SanitizeFilename removes or replaces characters that are invalid in filenames This is a standalone function for use by callers

func SanitizeFolderPath

func SanitizeFolderPath(s string) string

SanitizeFolderPath sanitizes a folder name by replacing invalid filesystem characters

Types

type Context

type Context struct {
	// Basic identifiers
	ID        string
	ContentID string

	// Title information
	Title         string
	OriginalTitle string // Japanese/original language title

	// Date information
	ReleaseDate *time.Time
	Runtime     int // in minutes

	// People
	Director  string
	Actresses []string // Array of actress names
	FirstName string   // For single actress context
	LastName  string   // For single actress context

	// Production info
	Maker  string // Studio/Maker
	Label  string
	Series string

	// Categories
	Genres []string

	// Media info
	OriginalFilename string
	VideoFilePath    string // Path to video file for mediainfo extraction

	// Indexing (for screenshots, multi-part, etc.)
	Index int

	// Multi-part file information
	PartNumber  int    // Part number (1, 2, 3, etc.) - 0 means single file
	PartSuffix  string // Original part suffix detected from filename (e.g., "-pt1", "-A")
	IsMultiPart bool   // Whether this is a multi-part file

	// Additional metadata
	Rating      float64
	Description string
	CoverURL    string
	TrailerURL  string

	// Output configuration
	GroupActress bool // Replace multiple actresses with "@Group"
	// contains filtered or unexported fields
}

Context holds all data available for template execution

func NewContextFromMovie

func NewContextFromMovie(movie *models.Movie) *Context

NewContextFromMovie creates a template context from a Movie model

func NewContextFromScraperResult

func NewContextFromScraperResult(result *models.ScraperResult) *Context

NewContextFromScraperResult creates a template context from a ScraperResult

func (*Context) Clone

func (c *Context) Clone() *Context

Clone creates a copy of the context

func (*Context) GetMediaInfo

func (c *Context) GetMediaInfo() *mediainfo.VideoInfo

GetMediaInfo lazy-loads and caches video metadata

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is a template processor for format strings

func NewEngine

func NewEngine() *Engine

NewEngine creates a new template engine

func (*Engine) Execute

func (e *Engine) Execute(template string, ctx *Context) (string, error)

Execute processes a template string with the given context

func (*Engine) TruncateTitle

func (e *Engine) TruncateTitle(title string, maxLen int) string

TruncateTitle smartly truncates a title to maxLen characters

func (*Engine) TruncateTitleBytes

func (e *Engine) TruncateTitleBytes(title string, maxBytes int) string

TruncateTitleBytes smartly truncates a title to fit within maxBytes (byte length) This is needed because file paths have byte length limits, not rune count limits

func (*Engine) ValidatePathLength

func (e *Engine) ValidatePathLength(path string, maxLen int) error

ValidatePathLength checks if a path exceeds the maximum length

Jump to

Keyboard shortcuts

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