customformat

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

func ScoreRelease

func ScoreRelease(matched []string, profileScores map[string]int) int

ScoreRelease computes the total custom format score for a release given the matched format IDs and a quality profile's per-format scores.

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

func NewService(q dbgen.Querier) *Service

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) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete removes a custom format by ID.

func (*Service) Export

func (s *Service) Export(ctx context.Context, ids []string) ([]byte, error)

Export serializes the given custom format IDs as TRaSH-compatible JSON. If ids is empty, all formats are exported.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (CustomFormat, error)

Get returns a single custom format by ID.

func (*Service) Import

func (s *Service) Import(ctx context.Context, data []byte) ([]CustomFormat, error)

Import parses TRaSH-format JSON (single format or array) and creates custom formats. Returns the created formats.

func (*Service) ImportPreset

func (s *Service) ImportPreset(ctx context.Context, presetID string) (CustomFormat, error)

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

func (s *Service) ListPresets() []presets.Preset

ListPresets returns all available built-in preset custom formats.

func (*Service) ListScores

func (s *Service) ListScores(ctx context.Context, profileID string) (map[string]int, error)

ListScores returns the custom format scores for a quality profile.

func (*Service) SetScores

func (s *Service) SetScores(ctx context.Context, profileID string, scores map[string]int) error

SetScores replaces all 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.

Directories

Path Synopsis
Package presets provides built-in TRaSH-compatible custom format definitions that users can import with a single click.
Package presets provides built-in TRaSH-compatible custom format definitions that users can import with a single click.

Jump to

Keyboard shortcuts

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