class

ArrJanitor::SonarrBackend

Inherits ArrJanitor::Backend < Reference < Object

Backend backed by the sonarr shard. Wraps a Sonarr::Client built from a Config::Backend and maps Sonarr's models onto ArrJanitor's structs.

Network errors are not swallowed: any failed Sonarr request raises (Sonarr::ApiError) for the scheduler/janitor to log.

Constants

QUEUE_PAGE_SIZE = 100

Page size used when walking the (paged) queue endpoint.

Constructors

new(config : Config::Backend)
Source

Class methods

build_download_client_info(resource : Sonarr::Model::DownloadClientResource) : DownloadClientInfo

Builds a DownloadClientInfo from a Sonarr download-client resource, reading host/port/useSsl/urlBase out of its fields.

Source
map_queue_item(record : Sonarr::Model::QueueResource) : QueueItem

Maps a Sonarr queue record onto a QueueItem.

Source
released_episode?(episode : Sonarr::Model::EpisodeResource, now : Time = Time.utc) : Bool

Whether episode has aired by now (both compared in UTC).

Source

Instance methods

config

The Config::Backend this backend was built from.

Source
delete_and_blocklist(item : QueueItem) : Nil

Deletes the queue record, removing it from the download client and adding it to the blocklist.

Source
download_client_info(name : String) : DownloadClientInfo | Nil

Resolves the Sonarr download client named name to connection details pulled from its fields array.

Source
interval_span

Poll interval between scans.

Source
name

Human-readable backend name (from config).

Source
queue

Fetches the full queue, following paging until every record is collected.

Source
released?(item : QueueItem) : Bool

True when the item's episode has aired (air-date on/before now) — Sonarr's notion of an episode being released/available.

Source
search(item : QueueItem) : Nil

Issues an EpisodeSearch command for the item's episode, falling back to a SeriesSearch when there is no episode id.

Source