class

ArrTop::SonarrBackend

Inherits ArrTop::Backend < Reference < Object

Backend backed by the sonarr shard. Wraps a Sonarr::Client and maps Sonarr's queue records onto normalized QueueRows. The queue is episode-based, so media_kind is :episode and dest_folder comes from the embedded series' path.

Network errors are not swallowed: a failed Sonarr request raises Sonarr::ApiError for the caller (the Poller) to handle.

Constants

QUEUE_PAGE_SIZE = 100

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

Constructors

new(name : String, url : String, api_key : String)
Source

Class methods

episode_media_name(series_title : String | Nil, season : Int32 | Nil, episode : Int32 | Nil) : String | Nil

Builds the media-column display name for an episode: the series title with an SxxEyy code appended when both season and episode are known (e.g. "The Show S02E03"). Falls back to just the series title (or nil) when the season/episode isn't known. Pure, so it's unit-testable.

Source
map_row(record : Sonarr::Model::QueueResource, backend_name : String) : QueueRow

Pure mapping seam: turns a Sonarr queue record into a QueueRow.

Source
to_i64(value : Float64 | Nil) : Int64

Converts the shard's Float64? byte counts to Int64 (nil → 0).

Source
warning?(status : Sonarr::TrackedDownloadStatus | Nil) : Bool

True when the tracked download status signals a warning or error.

Source

Instance methods

name

Human-readable backend name (from config).

Source
rows

Fetches the full queue, following paging until every record is collected. include_series: true so series.path is available for dest_folder, and include_episode: true so record.episode (hence episode_number) is populated — without it every season-pack row's episode is nil and the per-episode file matching silently falls back to the folder's newest file, making all episodes show the same (wrong) percentage.

Source