Documentation
¶
Overview ¶
Package customformat implements Radarr-compatible custom format management. Custom formats are user-defined scoring rules that evaluate releases against a set of conditions (specifications). Each condition matches against a specific aspect of a release (title regex, source, resolution, indexer flags, etc.). Matched formats contribute scores to release ranking within quality profiles.
Index ¶
- Constants
- func MatchRelease(formats []CustomFormat, release ReleaseInfo) []string
- func ScoreRelease(matched []string, profileScores map[string]int) int
- type CreateRequest
- type CustomFormat
- type ReleaseInfo
- type Service
- func (s *Service) Create(ctx context.Context, req CreateRequest) (CustomFormat, error)
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) Export(ctx context.Context, ids []string) ([]byte, error)
- func (s *Service) Get(ctx context.Context, id string) (CustomFormat, error)
- func (s *Service) Import(ctx context.Context, data []byte) ([]CustomFormat, error)
- func (s *Service) ImportPreset(ctx context.Context, presetID string) (CustomFormat, error)
- func (s *Service) List(ctx context.Context) ([]CustomFormat, error)
- func (s *Service) ListPresets() []presets.Preset
- func (s *Service) ListScores(ctx context.Context, profileID string) (map[string]int, error)
- func (s *Service) SetScores(ctx context.Context, profileID string, scores map[string]int) error
- func (s *Service) Update(ctx context.Context, id string, req UpdateRequest) (CustomFormat, error)
- type Specification
- type UpdateRequest
Constants ¶
const ( ImplReleaseTitle = "release_title" ImplEdition = "edition" ImplLanguage = "language" ImplIndexerFlag = "indexer_flag" ImplSource = "source" ImplResolution = "resolution" ImplQualityModifier = "quality_modifier" ImplSize = "size" ImplReleaseGroup = "release_group" ImplYear = "year" ImplAudioCodec = "audio_codec" ImplAudioChannels = "audio_channels" )
Valid implementation types for specifications.
Variables ¶
This section is empty.
Functions ¶
func MatchRelease ¶
func MatchRelease(formats []CustomFormat, release ReleaseInfo) []string
MatchRelease evaluates all custom formats against a release. Returns the IDs of formats that match.
Types ¶
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name"`
IncludeWhenRenaming bool `json:"include_when_renaming"`
Specifications []Specification `json:"specifications"`
}
CreateRequest holds fields needed to create a custom format.
type CustomFormat ¶
type CustomFormat struct {
ID string `json:"id"`
Name string `json:"name"`
IncludeWhenRenaming bool `json:"include_when_renaming"`
Specifications []Specification `json:"specifications"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
CustomFormat is the domain representation of a custom format.
type ReleaseInfo ¶
type ReleaseInfo struct {
Title string
Edition string
Languages []string
IndexerFlags []string
Source string
Resolution string
Modifier string // "remux", "brdisk", "rawhd", etc.
SizeBytes int64
ReleaseGroup string
Year int
AudioCodec string
AudioChannels string
}
ReleaseInfo is the input to the matcher — extracted from release title + indexer metadata.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages custom format CRUD.
func NewService ¶
NewService creates a new custom format Service.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, req CreateRequest) (CustomFormat, error)
Create creates a new custom format.
func (*Service) Export ¶
Export serializes the given custom format IDs as TRaSH-compatible JSON. If ids is empty, all formats are exported.
func (*Service) Import ¶
Import parses TRaSH-format JSON (single format or array) and creates custom formats. Returns the created formats.
func (*Service) ImportPreset ¶
ImportPreset imports a built-in preset by its stable ID using the existing TRaSH import pathway.
func (*Service) List ¶
func (s *Service) List(ctx context.Context) ([]CustomFormat, error)
List returns all custom formats ordered by name.
func (*Service) ListPresets ¶
ListPresets returns all available built-in preset custom formats.
func (*Service) ListScores ¶
ListScores returns the custom format scores for a quality profile.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, id string, req UpdateRequest) (CustomFormat, error)
Update modifies an existing custom format.
type Specification ¶
type Specification struct {
Name string `json:"name"`
Implementation string `json:"implementation"`
Negate bool `json:"negate"`
Required bool `json:"required"`
Fields map[string]string `json:"fields"`
}
Specification is a single condition within a custom format.
type UpdateRequest ¶
type UpdateRequest struct {
Name string `json:"name"`
IncludeWhenRenaming bool `json:"include_when_renaming"`
Specifications []Specification `json:"specifications"`
}
UpdateRequest holds fields needed to update a custom format.