sonarr

package module
v0.0.0-...-ec124ce Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: MIT Imports: 9 Imported by: 0

README

go-sonarr-client

GoDoc Reference Go Report Card

Go client library for the Sonarr API

TODO

  • Add Series
  • Run commands on the server
  • Automated testing

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorPathAlreadyConfigured = errors.New("Path is already configured for another series")

ErrorPathAlreadyConfigured path exists for another series

View Source
var ErrorSeriesExists = errors.New("This series has already been added")

ErrorSeriesExists error when trying to add an already added series

Functions

This section is empty.

Types

type Calendar

type Calendar struct {
	SeriesID                 int       `json:"seriesId"`
	EpisodeFileID            int       `json:"episodeFileId"`
	SeasonNumber             int       `json:"seasonNumber"`
	EpisodeNumber            int       `json:"episodeNumber"`
	Title                    string    `json:"title"`
	AirDate                  string    `json:"airDate"`
	AirDateUTC               time.Time `json:"airDateUtc"`
	HasFile                  bool      `json:"hasFile"`
	Monitored                bool      `json:"monitored"`
	AbsoluteEpisodeNumber    int       `json:"absoluteEpisodeNumber"`
	Series                   Series    `json:"series"`
	UnverifiedSceneNumbering bool      `json:"unverifiedSceneNumbering"`
}

Calendar entry for a past or upcoming airing.

type DiskSpace

type DiskSpace struct {
	Path       string `json:"path"`
	Label      string `json:"label"`
	FreeSpace  int    `json:"freeSpace"`
	TotalSpace int    `json:"totalSpace"`
}

DiskSpace remaining on each drive mounted on the server.

type Episode

type Episode struct {
	SeriesID                 int       `json:"seriesId"`
	EpisodeFileID            int       `json:"episodeFileID"`
	SeasonNumber             int       `json:"seasonNumber"`
	EpisodeNumber            int       `json:"episodeNumber"`
	Title                    string    `json:"title"`
	AirDate                  string    `json:"airDate"`
	AirDateUTC               time.Time `json:"airDateUTC"`
	Overview                 string    `json:"overview"`
	HasFile                  bool      `json:"hasFile"`
	Monitored                bool      `json:"monitored"`
	UnverifiedSceneNumbering bool      `json:"unverifiedSceneNumbering"`
	ID                       int       `json:"id"`
}

Episode of a Series.

type EpisodeFile

type EpisodeFile struct {
	SeriesID            int     `json:"seriesId"`
	SeasonNumber        int     `json:"seasonNumber"`
	RelativePath        string  `json:"relativePath"`
	Path                string  `json:"path"`
	Size                int     `json:"size"`
	DateAdded           string  `json:"dateAdded"`
	SceneName           string  `json:"sceneName"`
	Quality             Quality `json:"quality"`
	QualityCutoffNotMet bool    `json:"qualityCutoffNotMet"`
	ID                  int     `json:"id"`
}

EpisodeFile of an Episode. Represents a file stored on disk.

type ErrorMessage

type ErrorMessage struct {
	PropertyName                      string      `json:"propertyName"`
	Message                           string      `json:"errorMessage"`
	AttemptedValue                    interface{} `json:"attemptedValue"`
	FormattedMessageArguments         []string    `json:"formattedMessageArguments"`
	FormattedMessagePlaceholderValues struct {
		PropertyName  string      `json:"propertyName"`
		PropertyValue interface{} `json:"propertyValue"`
	} `json:"formattedMessagePlaceholderValues"`
}

ErrorMessage radarr's error message struct

type Profile

type Profile struct {
	Cutoff struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"cutoff"`
	ID    int `json:"id"`
	Items []struct {
		Allowed bool `json:"allowed"`
		Quality struct {
			ID   int    `json:"id"`
			Name string `json:"name"`
		} `json:"quality"`
	} `json:"items"`
	Language      string `json:"language"`
	Name          string `json:"name"`
	PreferredTags string `json:"preferredTags"`
}

Profile ...

type Quality

type Quality struct {
	Quality struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"quality"`
	Revision struct {
		Version int `json:"version"`
		Real    int `json:"real"`
	} `json:"revision"`
	Proper bool `json:"proper"`
}

Quality of a file.

type Queue

type Queue struct {
	Series                Series  `json:"series"`
	Episode               Episode `json:"episode"`
	Quality               Quality `json:"quality"`
	Size                  int     `json:"size"`
	Title                 string  `json:"title"`
	SizeLeft              int     `json:"sizeLeft"`
	Status                string  `json:"status"`
	TrackedDownloadStatus string  `json:"trackedDownloadStatus"`
	StatusMessages        []struct {
		Title    string   `json:"title"`
		Messages []string `json:"messages"`
	} `json:"statusMessages"`
	DownloadID string `json:"downloadId"`
	Protocol   string `json:"protocol"`
	ID         int    `json:"id"`
}

Queue item currently being downloaded.

type RootFolder

type RootFolder struct {
	FreeSpace       int    `json:"freeSpace"`
	ID              int    `json:"id"`
	Path            string `json:"path"`
	UnmappedFolders []struct {
		Name string `json:"name"`
		Path string `json:"path"`
	} `json:"unmappedFolders"`
}

RootFolder ...

type SearchResults

type SearchResults struct {
	Added         string   `json:"added"`
	AirTime       string   `json:"airTime"`
	Certification string   `json:"certification"`
	CleanTitle    string   `json:"cleanTitle"`
	FirstAired    string   `json:"firstAired"`
	Genres        []string `json:"genres"`
	Images        []struct {
		CoverType string `json:"coverType"`
		URL       string `json:"url"`
	} `json:"images"`
	ImdbID           string `json:"imdbId"`
	Monitored        bool   `json:"monitored"`
	Network          string `json:"network"`
	Overview         string `json:"overview"`
	ProfileID        int    `json:"profileId"`
	QualityProfileID int    `json:"qualityProfileId"`
	Ratings          struct {
		Value float64 `json:"value"`
		Votes int     `json:"votes"`
	} `json:"ratings"`
	RemotePoster string `json:"remotePoster"`
	Runtime      int    `json:"runtime"`
	SeasonCount  int    `json:"seasonCount"`
	SeasonFolder bool   `json:"seasonFolder"`
	Seasons      []struct {
		Monitored    bool `json:"monitored"`
		SeasonNumber int  `json:"seasonNumber"`
	} `json:"seasons"`
	SeriesType        string   `json:"seriesType"`
	SortTitle         string   `json:"sortTitle"`
	Status            string   `json:"status"`
	Tags              []string `json:"tags"`
	Title             string   `json:"title"`
	TitleSlug         string   `json:"titleSlug"`
	TvMazeID          int      `json:"tvMazeId"`
	TvRageID          int      `json:"tvRageId"`
	TvdbID            int      `json:"tvdbId"`
	UseSceneNumbering bool     `json:"useSceneNumbering"`
	Year              int      `json:"year"`
}

SearchResults are results of Sonarr's online series lookup not the results of what's already located on the Sonarr server

type Series

type Series struct {
	Title      string `json:"title"`
	AddOptions struct {
		IgnoreEpisodesWithFiles    bool `json:"ignoreEpisodesWithFiles"`
		IgnoreEpisodesWithoutFiles bool `json:"ignoreEpisodesWithoutFiles"`
		SearchForMissingEpisodes   bool `json:"searchForMissingEpisodes"`
	} `json:"addOptions"`
	AlternateTitles []struct {
		Title        string `json:"title"`
		SeasonNumber int    `json:"seasonNumber"`
	} `json:"alternateTitles"`
	SortTitle         string    `json:"sortTitle"`
	SeasonCount       int       `json:"seasonCount"`
	TotalEpisodeCount int       `json:"totalEpisodeCount"`
	EpisodeCount      int       `json:"episodeCount"`
	EpisodeFileCount  int       `json:"episodeFileCount"`
	SizeOnDisk        int       `json:"sizeOnDisk"`
	Status            string    `json:"status"`
	Overview          string    `json:"overview"`
	PreviousAiring    time.Time `json:"previousAiring"`
	Network           string    `json:"network"`
	AirTime           string    `json:"airTime"`
	Images            []struct {
		CoverType string `json:"coverType"`
	} `json:"images"`
	Seasons []struct {
		SeasonNumber int  `json:"seasonNumber"`
		Monitored    bool `json:"monitored"`
		Statistics   struct {
			PreviousAiring    time.Time `json:"previousAiring"`
			EpisodeFileCount  int       `json:"episodeFileCount"`
			EpisodeCount      int       `json:"episodeCount"`
			TotalEpisodeCount int       `json:"totalEpisodeCount"`
			SizeOnDisk        int       `json:"sizeOnDisk"`
			PercentOfEpisodes int       `json:"percentOfEpisodes"`
		} `json:"statistics"`
	} `json:"seasons"`
	Year              int       `json:"year"`
	Path              string    `json:"path"`
	ProfileID         int       `json:"profileId"`
	SeasonFolder      bool      `json:"seasonFolder"`
	Monitored         bool      `json:"monitored"`
	UseSceneNumbering bool      `json:"useSceneNumbering"`
	Runtime           int       `json:"runtime"`
	TvdbID            int       `json:"tvdbId"`
	TvRageID          int       `json:"tvRageId"`
	TvMazeID          int       `json:"tvMazeId"`
	FirstAired        time.Time `json:"firstAired"`
	LastInfoSync      time.Time `json:"lastInfoSync"`
	SeriesType        string    `json:"seriesType"`
	CleanTitle        string    `json:"cleanTitle"`
	ImdbID            string    `json:"imdbId"`
	TitleSlug         string    `json:"titleSlug"`
	Certification     string    `json:"certification"`
	Genres            []string  `json:"genres"`
	Tags              []int     `json:"tags"`
	Added             time.Time `json:"added"`
	Ratings           struct {
		Votes int     `json:"votes"`
		Value float32 `json:"value"`
	} `json:"ratings"`
	RootFolderPath   string `json:"rootFolderPath"`
	QualityProfileID int    `json:"qualityProfileId"`
	ID               int    `json:"id"`
}

Series stored on the Sonarr server.

type Sonarr

type Sonarr struct {
	HTTPClient http.Client
	// Timeout in seconds -- default 5
	Timeout int
	// contains filtered or unexported fields
}

Sonarr contains fields needed to make API calls to a Sonarr server

func New

func New(apiURL, apiKey string) (*Sonarr, error)

New creates a new Sonarr client instance.

func (Sonarr) AddSeries

func (s Sonarr) AddSeries(series Series) []error

AddSeries adds a movie to your wanted list

func (*Sonarr) DeleteEpisodeFile

func (s *Sonarr) DeleteEpisodeFile(episodeFileID int) (*EpisodeFile, error)

DeleteEpisodeFile deletes the EpisodeFile with the given ID. This also deletes the media file from disk!

func (*Sonarr) DeleteSeries

func (s *Sonarr) DeleteSeries(seriesID int, deleteFiles bool) (*Series, error)

DeleteSeries deletes the Series with the given ID. If deleteFiles is true, the series folder and all files will be deleted too.

func (*Sonarr) GetAllSeries

func (s *Sonarr) GetAllSeries() ([]Series, error)

GetAllSeries retrieves all Series.

func (*Sonarr) GetCalendar

func (s *Sonarr) GetCalendar(start, end string) ([]Calendar, error)

GetCalendar retrieves info about when episodes were/will be downloaded. If start and end are not provided, retrieves episodes airing today and tomorrow.

func (*Sonarr) GetDiskSpace

func (s *Sonarr) GetDiskSpace() ([]DiskSpace, error)

GetDiskSpace retrieves info about the disk space remaining on the server.

func (*Sonarr) GetEpisode

func (s *Sonarr) GetEpisode(episodeID int) (*Episode, error)

GetEpisode retrieves the Episode with the given ID.

func (*Sonarr) GetEpisodeFile

func (s *Sonarr) GetEpisodeFile(episodeFileID int) (*EpisodeFile, error)

GetEpisodeFile retrieves the EpisodeFile with the given ID.

func (*Sonarr) GetEpisodeFiles

func (s *Sonarr) GetEpisodeFiles(seriesID int) ([]EpisodeFile, error)

GetEpisodeFiles retrieves all EpisodeFiles for the given series ID.

func (*Sonarr) GetEpisodes

func (s *Sonarr) GetEpisodes(seriesID int) ([]Episode, error)

GetEpisodes retrieves all Episodes for the given series ID.

func (Sonarr) GetProfiles

func (s Sonarr) GetProfiles() ([]Profile, error)

GetProfiles returns all movie quality settings

func (Sonarr) GetRootFolders

func (s Sonarr) GetRootFolders() ([]RootFolder, error)

GetRootFolders returns available root folders

func (*Sonarr) GetSeries

func (s *Sonarr) GetSeries(seriesID int) (*Series, error)

GetSeries retrieves the Series with the given ID.

func (*Sonarr) GetSeriesFromTVDB

func (s *Sonarr) GetSeriesFromTVDB(seriesID int) (*Series, error)

GetSeriesFromTVDB retrieves the Series with the given ID.

func (*Sonarr) GetSystemStatus

func (s *Sonarr) GetSystemStatus() (*SystemStatus, error)

GetSystemStatus retrieves system information about the Sonarr server.

func (*Sonarr) GetTags

func (s *Sonarr) GetTags() ([]Tag, error)

GetTags retrieves all Tags that have been applied to any series.

func (*Sonarr) Search

func (s *Sonarr) Search(title string) ([]SearchResults, error)

Search searches for media via tvdb (or Sonarr's default search engine)

func (*Sonarr) UpdateEpisode

func (s *Sonarr) UpdateEpisode(ep *Episode) (*Episode, error)

UpdateEpisode updates the given Episode. Currently, the API only supports updating the "Monitored" status. Any other changes are ignored. This should be an Episode you have previously retrieved with GetEpisodes() or GetEpisode(). The updated Episode is returned.

func (*Sonarr) UpdateSeries

func (s *Sonarr) UpdateSeries(ser *Series) (*Series, error)

UpdateSeries updates the given Series. This should be a Series you have previously retrieved with GetAllSeries() or GetSeries(). The updated Series is returned.

type SystemStatus

type SystemStatus struct {
	Version           string `json:"version"`
	BuildTime         string `json:"buildTime"`
	IsDebug           bool   `json:"isDebug"`
	IsProduction      bool   `json:"isProduction"`
	IsAdmin           bool   `json:"isAdmin"`
	IsUserInteractive bool   `json:"isUserInteractive"`
	StartupTime       string `json:"startupTime"`
	AppData           string `json:"appData"`
	OsName            string `json:"osName"`
	OsVersion         string `json:"osVersion"`
	IsMonoRuntime     bool   `json:"isMonoRuntime"`
	IsMono            bool   `json:"isMono"`
	IsLinux           bool   `json:"isLinux"`
	IsOsx             bool   `json:"isOsx"`
	IsWindows         bool   `json:"isWindows"`
	Branch            string `json:"branch"`
	Authentication    string `json:"forms"`
	SqlliteVersion    string `json:"sqlliteVersion"`
	URLBase           string `json:"urlBase"`
	RuntimeVersion    string `json:"runtimeVersion"`
	RuntimeName       string `json:"runtimeName"`
}

SystemStatus of the server.

type Tag

type Tag struct {
	Label string `json:"label"`
	ID    int    `json:"id"`
}

Tag used to tag Series.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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