starr

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 9 Imported by: 0

README

Starr

Library for interacting with Radarr and Sonarr APIs. Maybe Lidarr too.

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"`
	Tag      string   `json:"tag" toml:"tag" xml:"tag" yaml:"tag"` // 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 {
	Movie struct {
		Title             string `json:"title"`
		AlternativeTitles []struct {
			SourceType string `json:"sourceType"`
			MovieID    int64  `json:"movieId"`
			Title      string `json:"title"`
			SourceID   int64  `json:"sourceId"`
			Votes      int64  `json:"votes"`
			VoteCount  int64  `json:"voteCount"`
			Language   string `json:"language"`
			ID         int64  `json:"id"`
		} `json:"alternativeTitles"`
		SecondaryYearSourceID int       `json:"secondaryYearSourceId"`
		SortTitle             string    `json:"sortTitle"`
		SizeOnDisk            int64     `json:"sizeOnDisk"`
		Status                string    `json:"status"`
		Overview              string    `json:"overview"`
		InCinemas             time.Time `json:"inCinemas"`
		PhysicalRelease       time.Time `json:"physicalRelease"`
		Images                []struct {
			CoverType string `json:"coverType"`
			URL       string `json:"url"`
		} `json:"images"`
		Website             string    `json:"website"`
		Downloaded          bool      `json:"downloaded"`
		Year                int       `json:"year"`
		HasFile             bool      `json:"hasFile"`
		YouTubeTrailerID    string    `json:"youTubeTrailerId"`
		Studio              string    `json:"studio"`
		Path                string    `json:"path"`
		ProfileID           int       `json:"profileId"`
		PathState           string    `json:"pathState"`
		Monitored           bool      `json:"monitored"`
		MinimumAvailability string    `json:"minimumAvailability"`
		IsAvailable         bool      `json:"isAvailable"`
		FolderName          string    `json:"folderName"`
		Runtime             int       `json:"runtime"`
		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                []string  `json:"tags"`
		Added               time.Time `json:"added"`
		Ratings             struct {
			Votes int64   `json:"votes"`
			Value float64 `json:"value"`
		} `json:"ratings"`
		QualityProfileID int64 `json:"qualityProfileId"`
		ID               int64 `json:"id"`
	} `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"`
	Size                    float64   `json:"size"`
	Title                   string    `json:"title"`
	Sizeleft                float64   `json:"sizeleft"`
	Timeleft                string    `json:"timeleft"`
	EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"`
	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         int64  `json:"id"`
}

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 {
		Title      string    `json:"title"`
		SortTitle  string    `json:"sortTitle"`
		SizeOnDisk int64     `json:"sizeOnDisk"`
		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"`
		Downloaded       bool      `json:"downloaded"`
		Year             int       `json:"year"`
		HasFile          bool      `json:"hasFile"`
		YouTubeTrailerID string    `json:"youTubeTrailerId"`
		Studio           string    `json:"studio"`
		Path             string    `json:"path"`
		ProfileID        int       `json:"profileId"`
		Monitored        bool      `json:"monitored"`
		Runtime          int       `json:"runtime"`
		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             []string  `json:"tags"`
		Added            time.Time `json:"added"`
		Ratings          struct {
			Votes int64   `json:"votes"`
			Value float64 `json:"value"`
		} `json:"ratings"`
		AlternativeTitles []string `json:"alternativeTitles"`
		QualityProfileID  int      `json:"qualityProfileId"`
		ID                int64    `json:"id"`
	} `json:"movie"`
	ID int `json:"id"`
}

RadarRecord is a record in Radarr History

type SonarQueue

type SonarQueue struct {
	Series struct {
		Title       string `json:"title"`
		SortTitle   string `json:"sortTitle"`
		SeasonCount int    `json:"seasonCount"`
		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"`
		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            int64     `json:"tvdbId"`
		TvRageID          int64     `json:"tvRageId"`
		TvMazeID          int64     `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              []string  `json:"tags"`
		Added             time.Time `json:"added"`
		Ratings           struct {
			Votes int64   `json:"votes"`
			Value float64 `json:"value"`
		} `json:"ratings"`
		QualityProfileID int `json:"qualityProfileId"`
		ID               int `json:"id"`
	} `json:"series"`
	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"`
		AbsoluteEpisodeNumber    int       `json:"absoluteEpisodeNumber"`
		UnverifiedSceneNumbering bool      `json:"unverifiedSceneNumbering"`
		ID                       int64     `json:"id"`
	} `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"`
	Size                    float64   `json:"size"`
	Title                   string    `json:"title"`
	Sizeleft                float64   `json:"sizeleft"`
	Timeleft                string    `json:"timeleft"`
	EstimatedCompletionTime time.Time `json:"estimatedCompletionTime"`
	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         int64  `json:"id"`
}

SonarQueue is the /api/queue endpoint.

Jump to

Keyboard shortcuts

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