starr

package module
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: MIT Imports: 9 Imported by: 26

README

Starr

Library for interacting with Radarr and Sonarr APIs. Maybe Lidarr too, but not yet.

This library is still reasonably featureless and could use more time and energy. It is currently used for a small CLI app that just extracts torrent downloads.

Can be easily expanded by adding more structs and methods to Config. It could also use a Get() function to return an interface.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey   string   `json:"api_key" toml:"api_key" xml:"api_key" yaml:"api_key"`
	URL      string   `json:"url" toml:"url" xml:"url" yaml:"url"`
	Path     string   `json:"path" toml:"path" xml:"path" yaml:"path"` // not used
	HTTPPass string   `json:"http_pass" toml:"http_pass" xml:"http_pass" yaml:"http_pass"`
	HTTPUser string   `json:"http_user" toml:"http_user" xml:"http_user" yaml:"http_user"`
	Timeout  Duration `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"`
}

Config is the data needed to poll Radarr or Sonarr.

func (*Config) RadarrHistory

func (c *Config) RadarrHistory() ([]*RadarRecord, error)

RadarrHistory returns the Radarr History (grabs/failures/completed)

func (*Config) RadarrQueue

func (c *Config) RadarrQueue() ([]*RadarQueue, error)

RadarrQueue returns the Radarr Queue (processing, but not yet imported)

func (*Config) Req

func (c *Config) Req(path string, params url.Values) ([]byte, error)

Req makes a http request, with some additions. path = "/query", params = "sort_by=timeleft&order=asc" (as url.Values)

func (*Config) SonarrQueue

func (c *Config) SonarrQueue() ([]*SonarQueue, error)

SonarrQueue returns the Sonarr Queue

type Duration

type Duration struct{ time.Duration }

Duration is used to UnmarshalTOML into a time.Duration value.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) (err error)

UnmarshalText parses a duration type from a config file.

type RadarHistory

type RadarHistory struct {
	Page          int            `json:"page"`
	PageSize      int            `json:"pageSize"`
	SortKey       string         `json:"sortKey"`
	SortDirection string         `json:"sortDirection"`
	TotalRecords  int64          `json:"totalRecords"`
	Records       []*RadarRecord `json:"Records"`
}

RadarHistory is the /api/history endpoint.

type RadarQueue

type RadarQueue struct {
	ID                      int64     `json:"id"`
	Size                    float64   `json:"size"`
	Sizeleft                float64   `json:"sizeleft"`
	EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"`
	Title                   string    `json:"title"`
	Timeleft                string    `json:"timeleft"`
	Status                  string    `json:"status"`
	TrackedDownloadStatus   string    `json:"trackedDownloadStatus"`
	DownloadID              string    `json:"downloadId"`
	Protocol                string    `json:"protocol"`
	Movie                   struct {
		Downloaded            bool          `json:"downloaded"`
		HasFile               bool          `json:"hasFile"`
		Monitored             bool          `json:"monitored"`
		IsAvailable           bool          `json:"isAvailable"`
		SecondaryYearSourceID int           `json:"secondaryYearSourceId"`
		Year                  int           `json:"year"`
		ProfileID             int           `json:"profileId"`
		Runtime               int           `json:"runtime"`
		QualityProfileID      int64         `json:"qualityProfileId"`
		ID                    int64         `json:"id"`
		TmdbID                int64         `json:"tmdbId"`
		SizeOnDisk            int64         `json:"sizeOnDisk"`
		InCinemas             time.Time     `json:"inCinemas"`
		PhysicalRelease       time.Time     `json:"physicalRelease"`
		LastInfoSync          time.Time     `json:"lastInfoSync"`
		Added                 time.Time     `json:"added"`
		Title                 string        `json:"title"`
		SortTitle             string        `json:"sortTitle"`
		Status                string        `json:"status"`
		Overview              string        `json:"overview"`
		Website               string        `json:"website"`
		YouTubeTrailerID      string        `json:"youTubeTrailerId"`
		Studio                string        `json:"studio"`
		Path                  string        `json:"path"`
		PathState             string        `json:"pathState"`
		MinimumAvailability   string        `json:"minimumAvailability"`
		FolderName            string        `json:"folderName"`
		CleanTitle            string        `json:"cleanTitle"`
		ImdbID                string        `json:"imdbId"`
		TitleSlug             string        `json:"titleSlug"`
		Genres                []string      `json:"genres"`
		Tags                  []interface{} `json:"tags"`
		AlternativeTitles     []interface{} `json:"alternativeTitles"`
		Images                []struct {
			CoverType string `json:"coverType"`
			URL       string `json:"url"`
		} `json:"images"`
		Ratings struct {
			Votes int64   `json:"votes"`
			Value float64 `json:"value"`
		} `json:"ratings"`
	} `json:"movie"`
	Quality struct {
		Quality struct {
			ID   int64  `json:"id"`
			Name string `json:"name"`
		} `json:"quality"`
		Revision struct {
			Version int64 `json:"version"`
			Real    int64 `json:"real"`
		} `json:"revision"`
	} `json:"quality"`
	StatusMessages []struct {
		Title    string   `json:"title"`
		Messages []string `json:"messages"`
	} `json:"statusMessages"`
}

RadarQueue is the /api/queue endpoint.

type RadarRecord

type RadarRecord struct {
	EpisodeID   int64  `json:"episodeId"`
	MovieID     int64  `json:"movieId"`
	SeriesID    int64  `json:"seriesId"`
	SourceTitle string `json:"sourceTitle"`
	Quality     struct {
		Quality struct {
			ID   int64  `json:"id"`
			Name string `json:"name"`
		} `json:"quality"`
		Revision struct {
			Version int64 `json:"version"`
			Real    int64 `json:"real"`
		} `json:"revision"`
	} `json:"quality"`
	QualityCutoffNotMet bool      `json:"qualityCutoffNotMet"`
	Date                time.Time `json:"date"`
	DownloadID          string    `json:"downloadId"`
	EventType           string    `json:"eventType"`
	Data                struct {
		Indexer         string    `json:"indexer"`
		NzbInfoURL      string    `json:"nzbInfoUrl"`
		ReleaseGroup    string    `json:"releaseGroup"`
		Age             string    `json:"age"`
		AgeHours        string    `json:"ageHours"`
		AgeMinutes      string    `json:"ageMinutes"`
		PublishedDate   time.Time `json:"publishedDate"`
		DownloadClient  string    `json:"downloadClient"`
		Size            string    `json:"size"`
		DownloadURL     string    `json:"downloadUrl"`
		GUID            string    `json:"guid"`
		TvdbID          string    `json:"tvdbId"`
		TvRageID        string    `json:"tvRageId"`
		Protocol        string    `json:"protocol"`
		TorrentInfoHash []string  `json:"torrentInfoHash"`
	} `json:"data"`
	Movie struct {
		Downloaded       bool      `json:"downloaded"`
		Monitored        bool      `json:"monitored"`
		HasFile          bool      `json:"hasFile"`
		Year             int       `json:"year"`
		ProfileID        int       `json:"profileId"`
		Runtime          int       `json:"runtime"`
		QualityProfileID int       `json:"qualityProfileId"`
		ID               int64     `json:"id"`
		SizeOnDisk       int64     `json:"sizeOnDisk"`
		Title            string    `json:"title"`
		SortTitle        string    `json:"sortTitle"`
		Status           string    `json:"status"`
		Overview         string    `json:"overview"`
		InCinemas        time.Time `json:"inCinemas"`
		Images           []struct {
			CoverType string `json:"coverType"`
			URL       string `json:"url"`
		} `json:"images"`
		Website          string        `json:"website"`
		YouTubeTrailerID string        `json:"youTubeTrailerId"`
		Studio           string        `json:"studio"`
		Path             string        `json:"path"`
		LastInfoSync     time.Time     `json:"lastInfoSync"`
		CleanTitle       string        `json:"cleanTitle"`
		ImdbID           string        `json:"imdbId"`
		TmdbID           int64         `json:"tmdbId"`
		TitleSlug        string        `json:"titleSlug"`
		Genres           []string      `json:"genres"`
		Tags             []interface{} `json:"tags"`
		Added            time.Time     `json:"added"`
		Ratings          struct {
			Votes int64   `json:"votes"`
			Value float64 `json:"value"`
		} `json:"ratings"`
		AlternativeTitles []string `json:"alternativeTitles"`
	} `json:"movie"`
	ID int `json:"id"`
}

RadarRecord is a record in Radarr History

type SonarQueue

type SonarQueue struct {
	ID                      int64     `json:"id"`
	EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"`
	Size                    float64   `json:"size"`
	Sizeleft                float64   `json:"sizeleft"`
	Title                   string    `json:"title"`
	Timeleft                string    `json:"timeleft"`
	Status                  string    `json:"status"`
	TrackedDownloadStatus   string    `json:"trackedDownloadStatus"`
	DownloadID              string    `json:"downloadId"`
	Protocol                string    `json:"protocol"`
	Series                  struct {
		SeasonFolder      bool          `json:"seasonFolder"`
		Monitored         bool          `json:"monitored"`
		UseSceneNumbering bool          `json:"useSceneNumbering"`
		Year              int           `json:"year"`
		ProfileID         int           `json:"profileId"`
		Runtime           int           `json:"runtime"`
		QualityProfileID  int           `json:"qualityProfileId"`
		ID                int           `json:"id"`
		SeasonCount       int           `json:"seasonCount"`
		TvdbID            int64         `json:"tvdbId"`
		TvRageID          int64         `json:"tvRageId"`
		TvMazeID          int64         `json:"tvMazeId"`
		FirstAired        time.Time     `json:"firstAired"`
		LastInfoSync      time.Time     `json:"lastInfoSync"`
		Added             time.Time     `json:"added"`
		Path              string        `json:"path"`
		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              []interface{} `json:"tags"`
		Title             string        `json:"title"`
		SortTitle         string        `json:"sortTitle"`
		Status            string        `json:"status"`
		Overview          string        `json:"overview"`
		Network           string        `json:"network"`
		AirTime           string        `json:"airTime"`
		Images            []struct {
			CoverType string `json:"coverType"`
			URL       string `json:"url"`
		} `json:"images"`
		Seasons []struct {
			SeasonNumber int  `json:"seasonNumber"`
			Monitored    bool `json:"monitored"`
		} `json:"seasons"`
		Ratings struct {
			Votes int64   `json:"votes"`
			Value float64 `json:"value"`
		} `json:"ratings"`
	} `json:"series"`
	Episode struct {
		HasFile                  bool      `json:"hasFile"`
		Monitored                bool      `json:"monitored"`
		UnverifiedSceneNumbering bool      `json:"unverifiedSceneNumbering"`
		SeriesID                 int       `json:"seriesId"`
		EpisodeFileID            int       `json:"episodeFileId"`
		SeasonNumber             int       `json:"seasonNumber"`
		EpisodeNumber            int       `json:"episodeNumber"`
		AbsoluteEpisodeNumber    int       `json:"absoluteEpisodeNumber"`
		ID                       int64     `json:"id"`
		AirDateUtc               time.Time `json:"airDateUtc"`
		Title                    string    `json:"title"`
		AirDate                  string    `json:"airDate"`
		Overview                 string    `json:"overview"`
	} `json:"episode"`
	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"`
	} `json:"quality"`

	StatusMessages []struct {
		Title    string   `json:"title"`
		Messages []string `json:"messages"`
	} `json:"statusMessages"`
}

SonarQueue is the /api/queue endpoint.

Jump to

Keyboard shortcuts

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