arrsvc

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package arrsvc composes the github.com/cplieger/arrapi Sonarr and Radarr clients with subflux's subtitle-specific operations: "wanted" iteration (which library items need a subtitle search), exclude-tag name resolution, and a fire-and-forget rescan. The raw library reads, per-item lookups, history polling, and connectivity ping are promoted from the embedded arrapi client unchanged, so this package adds only the app-level behavior arrapi deliberately does not provide.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AudioLanguages added in v0.4.0

func AudioLanguages(mi *arrapi.MediaInfo) []string

AudioLanguages parses a file's MediaInfo audio-languages string into deduplicated ISO 639-1 codes. Returns nil when mi is nil or empty.

func HasExcludeTag added in v0.4.0

func HasExcludeTag(tags []int, excludeIDs map[int]struct{}) bool

HasExcludeTag reports whether any of the item's tags are in the exclude set.

func OriginalLangCode added in v0.4.0

func OriginalLangCode(lang *arrapi.Language) string

OriginalLangCode returns the ISO 639-1 code for an arr original-language reference, or "" when the reference is nil or the name is unmapped.

func SeasonEpisodeFileCount added in v0.4.0

func SeasonEpisodeFileCount(s *arrapi.Series, seasonNum int) int

SeasonEpisodeFileCount returns the number of episode files for a specific season, using Sonarr's per-season statistics. Returns 0 if the season is not found or statistics are unavailable.

Types

type APIKey added in v0.4.0

type APIKey = arrapi.APIKey

APIKey is arrapi's credential type, re-exported so callers convert with arrsvc.APIKey(...) instead of importing arrapi for one cast. An alias, not a new type: it IS the library's type, and a second distinct one would add a conversion without adding a guarantee.

type Radarr

type Radarr struct {
	*arrapi.Radarr
}

Radarr composes arrapi.Radarr with subflux's wanted-movie iteration, exclude-tag resolution, and error-only rescan.

func NewRadarr

func NewRadarr(baseURL string, apiKey APIKey) (*Radarr, error)

NewRadarr builds a Radarr service for the given base URL and API key. The key is typed for the same reason NewSonarr's is.

func (*Radarr) RescanMovie

func (r *Radarr) RescanMovie(ctx context.Context, movieID int) error

RescanMovie asks Radarr to rescan the movie's folder for new or changed files. Fire-and-forget, like RescanSeries.

func (*Radarr) ResolveExcludeTagIDs

func (r *Radarr) ResolveExcludeTagIDs(ctx context.Context, names []string, logMissing bool) map[int]struct{}

ResolveExcludeTagIDs is the Radarr-side counterpart.

func (*Radarr) WantedMovies added in v0.4.0

func (r *Radarr) WantedMovies(ctx context.Context, excludeTagIDs map[int]struct{}, fn func(arrapi.Movie) error) error

WantedMovies invokes fn for every movie that needs a subtitle search. It fetches the full movie list first (closing that connection), then iterates locally, skipping movies with an excluded tag or no file.

type Sonarr

type Sonarr struct {
	*arrapi.Sonarr
}

Sonarr composes arrapi.Sonarr with subflux's wanted-episode iteration, exclude-tag resolution, and error-only rescan.

func NewSonarr

func NewSonarr(baseURL string, apiKey APIKey) (*Sonarr, error)

NewSonarr builds a Sonarr service for the given base URL and API key.

The key is typed rather than a second string: the two were adjacent and both strings, so a transposed pair compiled and dialled the API key as a URL, putting the credential in the connection error. The conversion to arrapi's type used to happen INSIDE this function — one level past the boundary a caller can actually get wrong.

func (*Sonarr) RescanSeries

func (s *Sonarr) RescanSeries(ctx context.Context, seriesID int) error

RescanSeries asks Sonarr to rescan the series' folder for new or changed files (subflux calls this after writing a subtitle). It is fire-and-forget: arrapi returns the queued command, which subflux does not poll, so only the error is surfaced.

func (*Sonarr) ResolveExcludeTagIDs

func (s *Sonarr) ResolveExcludeTagIDs(ctx context.Context, names []string, logMissing bool) map[int]struct{}

ResolveExcludeTagIDs returns the arr tag IDs matching the given tag names. When logMissing is true, names with no matching tag are logged once at INFO (coverage passes false to avoid repeating the message on every page load).

func (*Sonarr) WantedEpisodes added in v0.4.0

func (s *Sonarr) WantedEpisodes(ctx context.Context, excludeTagIDs map[int]struct{}, fn func(arrapi.Series, arrapi.Episode) error) error

WantedEpisodes invokes fn for every episode that needs a subtitle search. It fetches the full series list first (closing that connection), then fetches each non-excluded series' episodes concurrently (bounded to 6 goroutines), then invokes fn sequentially. A series whose episode fetch keeps failing is logged and skipped rather than aborting the whole scan.

Jump to

Keyboard shortcuts

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