Documentation
¶
Overview ¶
Package chapterremove parses and evaluates yt-dlp-compatible chapter removal specifications without depending on Python.
Index ¶
- Constants
- Variables
- type EvaluationBudget
- type Program
- func (program Program) Empty() bool
- func (program Program) HasPatterns() bool
- func (program Program) HasRanges() bool
- func (program Program) MatchTitle(ctx context.Context, title string) (bool, error)
- func (program Program) MatchTitleWithBudget(ctx context.Context, title string, budget *EvaluationBudget) (bool, error)
- func (program Program) ResolveRanges(duration float64) ([]Range, error)
- type Range
Constants ¶
const ( MaxSpecifications = 64 MaxSpecificationBytes = 4096 MaxTotalBytes = 64 << 10 MaxRanges = 256 // The chapter title language is a bounded Python regular-expression // search, matching the pinned ModifyChaptersPP use of regex.search(). // Keep these limits local to chapter removal: this package shares syntax // translation with match filters and metadata transforms, not their // execution policy. MaxRegexSourceBytes = 4096 MaxRegexTranslatedBytes = 16 << 10 MaxRegexInputBytes = 64 << 10 MaxRegexAttempts = 256 MaxRegexInspectedBytes = 4 << 20 RegexMatchTimeout = 25 * time.Millisecond RegexAggregateWallBudget = 250 * time.Millisecond )
Variables ¶
var ( ErrInvalidSpecification = errors.New("invalid chapter removal specification") ErrLimit = errors.New("chapter removal limit exceeded") )
Functions ¶
This section is empty.
Types ¶
type EvaluationBudget ¶
type EvaluationBudget struct {
// contains filtered or unexported fields
}
EvaluationBudget bounds one logical group of chapter-title searches. It is intentionally caller-owned so Program remains immutable and safe to reuse concurrently. A fresh budget is suitable for a single MatchTitle call; product code shares one budget across an entire media item's chapters.
func NewEvaluationBudget ¶
func NewEvaluationBudget() *EvaluationBudget
NewEvaluationBudget returns a bounded accounting object for a complete chapter-removal evaluation. It contains no source text or title data.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is an immutable, concurrency-safe chapter removal program.
func Parse ¶
Parse compiles repeatable --remove-chapters values. Values beginning with "*" are comma-separated time ranges; every other value is a title regular expression using search semantics.
func (Program) HasPatterns ¶
HasPatterns reports whether title matching was requested.
func (Program) MatchTitle ¶
MatchTitle reports whether any configured expression occurs in title.
func (Program) MatchTitleWithBudget ¶
func (program Program) MatchTitleWithBudget(ctx context.Context, title string, budget *EvaluationBudget) (bool, error)
MatchTitleWithBudget reports whether any configured Python expression searches title. The source, translated expression, input, number of attempts, inspected bytes, individual match time, and aggregate wall time are all bounded. Errors deliberately contain no pattern or title text.
func (Program) ResolveRanges ¶
ResolveRanges maps open range ends to duration and drops intervals wholly outside the media. Returned ranges are clamped but intentionally not merged; the shared cut planner performs stable overlap/adjacency merging.