Documentation
¶
Index ¶
- Constants
- func SanitizeFilename(s string) string
- func SanitizeFolderPath(s string) string
- type Context
- type Engine
- func (e *Engine) Execute(template string, ctx *Context) (string, error)
- func (e *Engine) ExecuteWithContext(execCtx context.Context, template string, ctx *Context) (string, error)
- func (e *Engine) TruncateTitle(title string, maxLen int) string
- func (e *Engine) TruncateTitleBytes(title string, maxBytes int) string
- func (e *Engine) Validate(template string) error
- func (e *Engine) ValidatePathLength(path string, maxLen int) error
- type EngineOptions
Constants ¶
const ( DefaultMaxTemplateBytes = 64 * 1024 DefaultMaxOutputBytes = 10 * 1024 * 1024 DefaultMaxConditionalDepth = 32 )
Variables ¶
This section is empty.
Functions ¶
func SanitizeFilename ¶
SanitizeFilename removes or replaces characters that are invalid in filenames This is a standalone function for use by callers
func SanitizeFolderPath ¶
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
ActressName string // Explicit actress name for .actors image filenames
// 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
// Translations keyed by normalized language code (e.g. "en", "ja")
// IMMUTABLE after construction - safe for concurrent read access
Translations map[string]models.MovieTranslation
// Optional per-context override for rendered language preference
// When empty, Engine default language is used
// IMPORTANT: Setting this changes behavior of unqualified tags like <TITLE>
DefaultLanguage 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 ¶
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 ¶
Clone creates a copy of the context. Preserves cached mediainfo to avoid duplicate expensive analysis.
func (*Context) GetMediaInfo ¶
GetMediaInfo lazy-loads and caches video metadata. Thread-safe: uses sync.Once to ensure single initialization even under concurrent access. Preserves pre-existing cached values from Clone() to avoid duplicate expensive analysis.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a template processor for format strings
func NewEngineWithOptions ¶
func NewEngineWithOptions(opts EngineOptions) *Engine
NewEngineWithOptions creates a new template engine with custom limits.
func (*Engine) ExecuteWithContext ¶
func (e *Engine) ExecuteWithContext(execCtx context.Context, template string, ctx *Context) (string, error)
ExecuteWithContext processes a template string with cancellation support and output limits.
func (*Engine) TruncateTitle ¶
TruncateTitle smartly truncates a title to maxLen characters
func (*Engine) TruncateTitleBytes ¶
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
type EngineOptions ¶
type EngineOptions struct {
MaxTemplateBytes int
MaxOutputBytes int
MaxConditionalDepth int
// Template language configuration (OPT-IN behavior change)
// Setting DefaultLanguage changes how unqualified tags like <TITLE> behave
DefaultLanguage string
FallbackLanguages []string
}
EngineOptions defines validation and execution limits for template rendering.