radarr

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

README

Radarr Go client

Go Report Card GitHub go.mod Go version Godoc Docker Pulls GitHub tag (latest SemVer)

This is a Go package that lets you to interact with your Radarr instance. Developed for Radarr API v2.

Radarr API v3 is under construction. See here and here.

You can use it as CLI. See related section

Supports

Here are the currently supported endpoints:

  • Calendar
  • Command
  • Diskspace
  • History
  • Movie
    • Returns all Movies in your collection
    • Returns the movie with the matching ID or 404 if no matching movie is found
    • Adds a new movie to your collection
    • Update an existing movie
    • Delete the movie with the given ID
  • Movie Lookup
  • Queue
  • List Exclusions
  • System-Status

Getting started

package main

import (
	"fmt"
	"log"

	"github.com/SkYNewZ/radarr"
)

// Instantiate a standard client
func main() {
	client, err := radarr.New("https://my.radarr-instance.fr", "radarr-api-key", nil)
	if err != nil {
		log.Fatalln(err)
	}

	movie, err := client.Movies.Get(217)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%s", movie.Title)

	// Output:
	// Frozen II
}

Documentation

Overview

Package radarr provide a Radarr https://github.com/Radarr/Radarr Go client

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientOptions added in v0.0.6

type ClientOptions struct {
	Verbose bool
}

ClientOptions describe optional value to create a Radarr client

type Command added in v0.0.2

type Command struct {
	Name string `json:"name"`
	Body struct {
		SendUpdatesToClient bool   `json:"sendUpdatesToClient"`
		UpdateScheduledTask bool   `json:"updateScheduledTask"`
		CompletionMessage   string `json:"completionMessage"`
		Name                string `json:"name"`
		Trigger             string `json:"trigger"`
	} `json:"body"`
	Priority            string    `json:"priority"`
	Status              string    `json:"status"`
	Queued              time.Time `json:"queued"`
	Trigger             string    `json:"trigger"`
	State               string    `json:"state"`
	Manual              bool      `json:"manual"`
	StartedOn           time.Time `json:"startedOn"`
	StateChangeTime     time.Time `json:"stateChangeTime"`
	SendUpdatesToClient bool      `json:"sendUpdatesToClient"`
	UpdateScheduledTask bool      `json:"updateScheduledTask"`
	ID                  int       `json:"id"`
}

Command describe a generic command

type CommandService added in v0.0.2

type CommandService struct {
	// contains filtered or unexported fields
}

CommandService not usable for now contains Radarr commands operations

func (*CommandService) CutOffUnmetMoviesSearch added in v0.0.2

func (c *CommandService) CutOffUnmetMoviesSearch(filter *Filter) *Command

CutOffUnmetMoviesSearch Instructs Radarr to search all cutoff unmet movies (Take care, since it could go over your indexers api limits!)

func (*CommandService) DownloadedMoviesScan added in v0.0.2

func (c *CommandService) DownloadedMoviesScan(opts ...*DownloadedMoviesScanOptions) *Command

DownloadedMoviesScan Instruct Radarr to scan the DroneFactoryFolder or a folder defined by the path variable. Each file and folder in the DroneFactoryFolder is interpreted as separate download. But a folder specified by the path variable is assumed to be a single download (job) and the folder name should be the release name. The downloadClientId can be used to support this API endpoint in conjunction with Completed Download Handling, so Radarr knows that a particular download has already been imported.

func (*CommandService) MissingMoviesSearch added in v0.0.2

func (c *CommandService) MissingMoviesSearch(filter *Filter) *Command

MissingMoviesSearch Instructs Radarr to search all missing movies. This functionality is similar to what CouchPotato does and runs a backlog search for all your missing movies. For example You can use this api with curl and crontab to instruct Radarr to run a backlog search on 1 AM everyday.

func (*CommandService) MoviesSearch added in v0.0.2

func (c *CommandService) MoviesSearch(movieIDs ...[]int) *Command

MoviesSearch Search for one or more movies

func (*CommandService) NetImportSync added in v0.0.2

func (c *CommandService) NetImportSync() *Command

NetImportSync Instructs Radarr to search all lists for movies not yet added to Radarr.

func (*CommandService) RefreshMovie added in v0.0.2

func (c *CommandService) RefreshMovie(movieID ...int) *Command

RefreshMovie Refresh movie information from TMDb and rescan disk

func (*CommandService) RenameFiles added in v0.0.2

func (c *CommandService) RenameFiles(files ...[]int) *Command

RenameFiles Instruct Radarr to rename the list of files provided.

func (*CommandService) RenameMovie added in v0.0.2

func (c *CommandService) RenameMovie(movieIDs ...[]int) *Command

RenameMovie Instruct Radarr to rename all files in the provided movies.

func (*CommandService) RescanMovie added in v0.0.2

func (c *CommandService) RescanMovie(movieID ...int) *Command

RescanMovie Rescan disk for movies

func (*CommandService) RssSync added in v0.0.2

func (c *CommandService) RssSync() *Command

RssSync Instruct Radarr to perform an RSS sync with all enabled indexers

func (*CommandService) Status added in v0.0.2

func (c *CommandService) Status(commandID string) *Command

Status Queries the status of a previously started command mathing given unique ID

func (*CommandService) StatusAll added in v0.0.2

func (c *CommandService) StatusAll() *Command

StatusAll Queries the status of all currently started commands.

type Commands added in v0.0.2

type Commands []Command

Commands is a set of commands

type Data added in v0.0.2

type Data struct {
	Reason          string    `json:"reason,omitempty"`
	DroppedPath     string    `json:"droppedPath,omitempty"`
	ImportedPath    string    `json:"importedPath,omitempty"`
	Indexer         string    `json:"indexer,omitempty"`
	NzbInfoURL      string    `json:"nzbInfoUrl,omitempty"`
	ReleaseGroup    string    `json:"releaseGroup,omitempty"`
	Age             string    `json:"age,omitempty"`
	AgeHours        string    `json:"ageHours,omitempty"`
	AgeMinutes      string    `json:"ageMinutes,omitempty"`
	PublishedDate   time.Time `json:"publishedDate,omitempty"`
	DownloadClient  string    `json:"downloadClient,omitempty"`
	Size            string    `json:"size,omitempty"`
	DownloadURL     string    `json:"downloadUrl,omitempty"`
	GUID            string    `json:"guid,omitempty"`
	TvdbID          string    `json:"tvdbId,omitempty"`
	TvRageID        string    `json:"tvRageId,omitempty"`
	Protocol        string    `json:"protocol,omitempty"`
	IndexerFlags    string    `json:"indexerFlags,omitempty"`
	IndexerID       string    `json:"indexerId,omitempty"`
	TorrentInfoHash string    `json:"torrentInfoHash,omitempty"`
}

Data contains arbitrary data

type DeleteMovieOptions added in v0.0.3

type DeleteMovieOptions struct {
	// If true the movie folder and all files will be deleted when the movie is deleted
	DeleteFiles bool

	// If true the movie TMDB ID will be added to the import exclusions list when the movie is deleted
	AddExclusion bool
}

DeleteMovieOptions optionnal option while deleting movie

type Diskspace added in v0.0.2

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

Diskspace disk space Radarr response

type DiskspaceService added in v0.0.2

type DiskspaceService struct {
	// contains filtered or unexported fields
}

DiskspaceService contains Radarr diskspace operations

func (*DiskspaceService) Get added in v0.0.2

func (s *DiskspaceService) Get() (*Diskspaces, error)

Get return Radarr disk space info

type Diskspaces added in v0.0.2

type Diskspaces []Diskspace

Diskspaces describe disk space info on your Radarr instance

type DownloadedMoviesScanOptions added in v0.0.2

type DownloadedMoviesScanOptions struct {
	Path             string     `json:"path"`
	DownloadClientID string     `json:"downloadClientId"`
	ImportMode       ImportMode `json:"importMode"`
}

DownloadedMoviesScanOptions available options when using DownloadedMoviesScanCommand

type Error

type Error struct {
	Code    int
	Message string
}

Error Radarr error response

func (*Error) Error

func (e *Error) Error() string

type ExcludedMovie added in v0.0.5

type ExcludedMovie struct {
	ID         int    `json:"id"`
	MovieTitle string `json:"movieTitle"`
	MovieYear  int    `json:"movieYear"`
	TmdbID     int    `json:"tmdbId"`
}

ExcludedMovie describe an excluded movie from being downloaded

type ExcludedMovies added in v0.0.5

type ExcludedMovies []*ExcludedMovie

ExcludedMovies descrive a set of excluded movies

type Filter added in v0.0.2

type Filter int

Filter filtering options when using MissingMoviesSearch and CutOffUnmetMoviesSearchCommand

const (
	// FilterByMonitored filter movies by monitored ones
	FilterByMonitored Filter = iota

	// FilterByNonMonitored filter movies by non monitored ones
	FilterByNonMonitored

	// FilterAll return all movies without filters
	FilterAll

	// FilterByStatusAndAvailable return 'availables' movies
	FilterByStatusAndAvailable

	// FilterByStatusAndReleased return 'released' movies
	FilterByStatusAndReleased

	// FilterByStatusAndInCinemas return 'inCinemas' movies
	FilterByStatusAndInCinemas

	// FilterByStatusAndAnnounced return 'announced' movies
	FilterByStatusAndAnnounced
)

type HTTPClientInterface

type HTTPClientInterface interface {
	Get(url string) (resp *http.Response, err error)
	Do(req *http.Request) (*http.Response, error)
}

HTTPClientInterface interface for the http.Client

type History added in v0.0.2

type History struct {
	Page          int      `json:"page"`
	PageSize      int      `json:"pageSize"`
	SortKey       string   `json:"sortKey"`
	SortDirection string   `json:"sortDirection"`
	TotalRecords  int      `json:"totalRecords"`
	Records       []Record `json:"records"`
}

History return your Radarr history

type HistoryService added in v0.0.2

type HistoryService struct {
	// contains filtered or unexported fields
}

HistoryService perform actions on your Radarr history

func (*HistoryService) Get added in v0.0.2

func (s *HistoryService) Get() (*Records, error)

Get return all history

type Images added in v0.0.2

type Images struct {
	CoverType string `json:"coverType"`
	URL       string `json:"url"`
}

Images movie images

type ImportMode added in v0.0.2

type ImportMode int

ImportMode can be used to override the default Copy for torrents with external preprocessing/transcoding/unrar.

const (
	// Move imported files instead of copy
	Move ImportMode = iota

	// Copy Or Hardlink depending on Radarr configuration
	Copy
)

func (ImportMode) String added in v0.0.2

func (i ImportMode) String() string

type LookupService added in v0.0.5

type LookupService struct {
	// contains filtered or unexported fields
}

LookupService contains Radarr movie lookup operations

func (*LookupService) Imdb added in v0.0.5

func (l *LookupService) Imdb(IMDBID string) (*Movie, error)

Imdb Search using IMDB id https://github.com/Radarr/Radarr/wiki/API:Movie-Lookup#search-using-imdb-id

func (*LookupService) Plain added in v0.0.5

func (l *LookupService) Plain(term string) (Movies, error)

Plain simply search movies matching given term https://github.com/Radarr/Radarr/wiki/API:Movie-Lookup#search-by-term

func (*LookupService) Tmdb added in v0.0.5

func (l *LookupService) Tmdb(TMDBID int) (*Movie, error)

Tmdb Search by The Movie Database ID https://github.com/Radarr/Radarr/wiki/API:Movie-Lookup#search-by-the-movie-database-id

type Movie

type Movie struct {
	Title             string `json:"title"`
	AlternativeTitles []struct {
		SourceType string `json:"sourceType"`
		MovieID    int    `json:"movieId"`
		Title      string `json:"title"`
		SourceID   int    `json:"sourceId"`
		Votes      int    `json:"votes"`
		VoteCount  int    `json:"voteCount"`
		Language   struct {
			ID   int    `json:"id"`
			Name string `json:"name"`
		} `json:"language"`
		ID int `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"`
	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              int       `json:"tmdbId"`
	TitleSlug           string    `json:"titleSlug"`
	Genres              []string  `json:"genres"`
	Tags                []int     `json:"tags"`
	Added               time.Time `json:"added"`
	Ratings             struct {
		Votes int     `json:"votes"`
		Value float64 `json:"value"`
	} `json:"ratings"`
	MovieFile struct {
		MovieID      int       `json:"movieId"`
		RelativePath string    `json:"relativePath"`
		Size         int64     `json:"size"`
		DateAdded    time.Time `json:"dateAdded"`
		SceneName    string    `json:"sceneName"`
		Quality      struct {
			Quality  Quality `json:"quality"`
			Revision struct {
				Version  int  `json:"version"`
				Real     int  `json:"real"`
				IsRepack bool `json:"isRepack"`
			} `json:"revision"`
		} `json:"quality"`
		Edition   string `json:"edition"`
		MediaInfo struct {
			ContainerFormat              string  `json:"containerFormat"`
			VideoFormat                  string  `json:"videoFormat"`
			VideoCodecID                 string  `json:"videoCodecID"`
			VideoProfile                 string  `json:"videoProfile"`
			VideoCodecLibrary            string  `json:"videoCodecLibrary"`
			VideoBitrate                 int     `json:"videoBitrate"`
			VideoBitDepth                int     `json:"videoBitDepth"`
			VideoMultiViewCount          int     `json:"videoMultiViewCount"`
			VideoColourPrimaries         string  `json:"videoColourPrimaries"`
			VideoTransferCharacteristics string  `json:"videoTransferCharacteristics"`
			Width                        int     `json:"width"`
			Height                       int     `json:"height"`
			AudioFormat                  string  `json:"audioFormat"`
			AudioCodecID                 string  `json:"audioCodecID"`
			AudioCodecLibrary            string  `json:"audioCodecLibrary"`
			AudioAdditionalFeatures      string  `json:"audioAdditionalFeatures"`
			AudioBitrate                 int     `json:"audioBitrate"`
			RunTime                      string  `json:"runTime"`
			AudioStreamCount             int     `json:"audioStreamCount"`
			AudioChannels                int     `json:"audioChannels"`
			AudioChannelPositions        string  `json:"audioChannelPositions"`
			AudioChannelPositionsText    string  `json:"audioChannelPositionsText"`
			AudioProfile                 string  `json:"audioProfile"`
			VideoFps                     float64 `json:"videoFps"`
			AudioLanguages               string  `json:"audioLanguages"`
			Subtitles                    string  `json:"subtitles"`
			ScanType                     string  `json:"scanType"`
			SchemaRevision               int     `json:"schemaRevision"`
		} `json:"mediaInfo"`
		ID int `json:"id"`
	} `json:"movieFile"`
	QualityProfileID int `json:"qualityProfileId"`
	ID               int `json:"id"`
}

Movie Radarr movie

type MovieService

type MovieService struct {
	Lookup *LookupService
	// contains filtered or unexported fields
}

MovieService contains Radarr movies operations

func (*MovieService) Delete added in v0.0.3

func (m *MovieService) Delete(movie *Movie, opts ...*DeleteMovieOptions) error

Delete given movie https://github.com/Radarr/Radarr/wiki/API:Movie#deleteid

func (*MovieService) Excluded added in v0.0.5

func (m *MovieService) Excluded() (ExcludedMovies, error)

Excluded Gets movies marked as List Exclusions https://github.com/Radarr/Radarr/wiki/API:List-Exclusions

func (*MovieService) Get

func (m *MovieService) Get(movieID int) (*Movie, error)

Get Returns all Movies in your collection https://github.com/Radarr/Radarr/wiki/API:Movie#getid

func (*MovieService) List

func (m *MovieService) List() (Movies, error)

List Returns the movie with the matching ID or eerror if no matching movie is found https://github.com/Radarr/Radarr/wiki/API:Movie#get

func (*MovieService) Upcoming

func (m *MovieService) Upcoming(opts ...*UpcomingOptions) (Movies, error)

Upcoming Gets upcoming movies from your Radarr library, if start/end are not supplied movies airing today and tomorrow will be returned Its match the physicalRelease attribute https://github.com/Radarr/Radarr/wiki/API:Calendar#get

Example (Advanced)
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/SkYNewZ/radarr"
)

func main() {
	client, err := radarr.New("https://my.radarr-instance.fr", "radarr-api-key", nil)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println("Search upcoming movies between April 5th and April 10th")
	start := time.Date(2020, time.April, 5, 0, 0, 0, 0, time.Local)
	end := time.Date(2020, time.April, 10, 0, 0, 0, 0, time.Local)
	movies, err := client.Movies.Upcoming(&radarr.UpcomingOptions{
		Start: &start,
		End:   &end,
	})
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Printf("%+v", movies)
}
Output:

Example (Basic)

Return upcoming movies by specifying period

package main

import (
	"fmt"
	"log"

	"github.com/SkYNewZ/radarr"
)

func main() {
	client, err := radarr.New("https://my.radarr-instance.fr", "radarr-api-key", nil)
	if err != nil {
		log.Fatalln(err)
	}

	movies, err := client.Movies.Upcoming()
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Printf("%+v", movies)
}
Output:

type Movies

type Movies []*Movie

Movies multiple Radarr movies

type Quality added in v0.0.2

type Quality struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Source     string `json:"source"`
	Resolution int    `json:"resolution"`
	Modifier   string `json:"modifier"`
}

Quality movir quality

type Ratings added in v0.0.2

type Ratings struct {
	Votes int     `json:"votes"`
	Value float64 `json:"value"`
}

Ratings your movies ratings

type Record added in v0.0.2

type Record struct {
	MovieID             int       `json:"movieId"`
	SourceTitle         string    `json:"sourceTitle"`
	Quality             Quality   `json:"quality"`
	QualityCutoffNotMet bool      `json:"qualityCutoffNotMet"`
	Date                time.Time `json:"date"`
	EventType           string    `json:"eventType"`
	Movie               Movie     `json:"movie"`
	ID                  int       `json:"id"`
	DownloadID          string    `json:"downloadId,omitempty"`
	Data                Data      `json:"data,omitempty"`
}

Record history item

type Records added in v0.0.2

type Records = []Record

Records is a set of Record

type Revision added in v0.0.2

type Revision struct {
	Version  int  `json:"version"`
	Real     int  `json:"real"`
	IsRepack bool `json:"isRepack"`
}

Revision movie revisions

type Service

Service containing all availables operations

func New

func New(radarrURL, apiKey string, client HTTPClientInterface, opts ...*ClientOptions) (*Service, error)

New Create a Radarr client Optionnally specify an http.Client

Example (Advanced)

Instantiate a client with a custom HTTP client

package main

import (
	"fmt"
	"log"
	"net/http"
	"time"

	"github.com/SkYNewZ/radarr"
)

func main() {
	client, err := radarr.New("https://my.radarr-instance.fr", "radarr-api-key", &http.Client{
		Timeout: time.Second * 10,
	})
	if err != nil {
		log.Fatalln(err)
	}

	movie, err := client.Movies.Get(217)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%s", movie.Title)
}
Output:

Example (Basic)

Instantiate a standard client

package main

import (
	"fmt"
	"log"

	"github.com/SkYNewZ/radarr"
)

func main() {
	client, err := radarr.New("https://my.radarr-instance.fr", "radarr-api-key", nil)
	if err != nil {
		log.Fatalln(err)
	}

	movie, err := client.Movies.Get(217)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%s", movie.Title)
}
Output:

Example (Verbose)
package main

import (
	"fmt"
	"log"

	"github.com/SkYNewZ/radarr"
)

func main() {
	client, err := radarr.New("https://my.radarr-instance.fr", "radarr-api-key", nil, &radarr.ClientOptions{
		Verbose: true,
	})
	if err != nil {
		log.Fatalln(err)
	}

	movie, err := client.Movies.Get(217)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%s", movie.Title)
}
Output:

type SystemStatus

type SystemStatus struct {
	Version           string    `json:"version"`
	BuildTime         time.Time `json:"buildTime"`
	IsDebug           bool      `json:"isDebug"`
	IsProduction      bool      `json:"isProduction"`
	IsAdmin           bool      `json:"isAdmin"`
	IsUserInteractive bool      `json:"isUserInteractive"`
	StartupPath       string    `json:"startupPath"`
	AppData           string    `json:"appData"`
	OsName            string    `json:"osName"`
	OsVersion         string    `json:"osVersion"`
	IsNetCore         bool      `json:"isNetCore"`
	IsMono            bool      `json:"isMono"`
	IsLinux           bool      `json:"isLinux"`
	IsOsx             bool      `json:"isOsx"`
	IsWindows         bool      `json:"isWindows"`
	Branch            string    `json:"branch"`
	Authentication    string    `json:"authentication"`
	SqliteVersion     string    `json:"sqliteVersion"`
	MigrationVersion  int       `json:"migrationVersion"`
	URLBase           string    `json:"urlBase"`
	RuntimeVersion    string    `json:"runtimeVersion"`
	RuntimeName       string    `json:"runtimeName"`
}

SystemStatus Radarr system status response

type SystemStatusService

type SystemStatusService struct {
	// contains filtered or unexported fields
}

SystemStatusService contains Radarr system operations

type UpcomingOptions

type UpcomingOptions struct {
	Start *time.Time
	End   *time.Time
}

UpcomingOptions describe period to search upcoming movies with

Directories

Path Synopsis
cmd
radarr
This package contains the code of the radarr executable
This package contains the code of the radarr executable

Jump to

Keyboard shortcuts

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