jobs

package
v0.0.0-...-5ceeed6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package jobs implements the transmissionrpc-powered job running system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToRemote

func ConnectToRemote(settings TransmissionSettings) (*transmissionrpc.Client, error)

ConnectToRemote creates an *transmissionrpc.Client.

func FetchSonarrDrops

func FetchSonarrDrops(settings SonarrSettings, maxRecords int) (paths map[string]bool, err error)

FetchSonarrDrops crawls Sonarr's history for filesystem drop paths, going back up to maxRecords items. If maxRecords <= 0, this exhausts all possbile history items.

Types

type Config

type Config struct {
	DatabasePath string `mapstructure:"database"`
	Transmission TransmissionSettings
	Sonarr       *SonarrSettings
	Jobs         []JobConfig
}

Config describes the schema of the .yml config file

type FeedMatchOptions

type FeedMatchOptions struct {
	Field  string
	RegExp string
	// contains filtered or unexported fields
}

FeedMatchOptions describes a regular expression to run on a particular feed field.

type FeedOptions

type FeedOptions struct {
	URL   string
	Tag   string            // optional
	Match *FeedMatchOptions // optional
}

FeedOptions describes how to add a torrent from an Atom/RSS feed.

func (*FeedOptions) Validate

func (f *FeedOptions) Validate() error

Validate returns whether this is a legit thing we can do or not (and caches some stuff)

type JobConfig

type JobConfig struct {
	Name          string
	Location      string
	SeedRatio     float64        `mapstructure:"seed_ratio"`
	RemoveOptions *RemoveOptions `mapstructure:"remove"`
	TagOptions    *TagOptions    `mapstructure:"tag"`
	FeedOptions   *FeedOptions   `mapstructure:"feed"`
}

JobConfig describes jobs to run. The presence of each 'SomethingOptions' field denotes the action.

type RemoveOptions

type RemoveOptions struct {
	DeleteLocal bool `mapstructure:"delete_local"`
	Condition   string
}

RemoveOptions describes when and how to remove a torrent.

type Runner

type Runner struct {
	Config  Config
	DryRun  bool
	Verbose bool
	// contains filtered or unexported fields
}

Runner is what actually runs all of the jobs

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) (err error)

Run runs the runner's configured jobs

type SonarrSettings

type SonarrSettings struct {
	Host   string
	APIKey string `mapstructure:"api_key"`
}

SonarrSettings describes how to connect to a Sonarr server.

type StoredTorrentInfo

type StoredTorrentInfo struct {
	ID       int64  `boltholdKey:"ID"`
	FeedGUID string `boltholdIndex:"FeedGUID"`
	Removed  bool
	Tags     []string
}

StoredTorrentInfo contains TransmissionTorrent info saved with bolthold. Usually embedded inside of TransmissionTorrent.

func (StoredTorrentInfo) SafeToPrune

func (s StoredTorrentInfo) SafeToPrune() bool

SafeToPrune returns whether a piece of stored torrent state is worth keeping around.

type TagOptions

type TagOptions struct {
	Name      string
	Condition string
	Ephemeral bool
}

TagOptions describes when and how to tag a torrent.

type TransmissionSettings

type TransmissionSettings struct {
	Host     string
	Username string
	Password string
}

TransmissionSettings describes how to connect to a Transmission RPC server.

type TransmissionTorrent

type TransmissionTorrent struct {
	ActivityDate            time.Time
	AddedDate               time.Time
	BandwidthPriority       int64
	Comment                 string
	CorruptEver             int64
	Creator                 string
	DateCreated             time.Time
	DesiredAvailable        int64
	DoneDate                time.Time
	DownloadDir             string
	DownloadedEver          int64
	DownloadLimit           int64
	DownloadLimited         bool
	Error                   int64
	ErrorString             string
	Eta                     int64
	EtaIdle                 int64
	Files                   []*transmissionrpc.TorrentFile
	FileStats               []*transmissionrpc.TorrentFileStat
	HashString              string
	HaveUnchecked           int64
	HaveValid               int64
	HonorsSessionLimits     bool
	ID                      int64
	IsFinished              bool
	IsPrivate               bool
	IsStalled               bool
	LeftUntilDone           int64
	MagnetLink              string
	ManualAnnounceTime      int64
	MaxConnectedPeers       int64
	MetadataPercentComplete float64
	Name                    string
	PeerLimit               int64
	Peers                   []*transmissionrpc.Peer
	PeersConnected          int64
	PeersFrom               transmissionrpc.TorrentPeersFrom
	PeersGettingFromUs      int64
	PeersSendingToUs        int64
	PercentDone             float64
	Pieces                  string
	PieceCount              int64
	PieceSize               cunits.Bits
	Priorities              []int64
	QueuePosition           int64
	RateDownload            int64
	RateUpload              int64
	RecheckProgress         float64
	SecondsDownloading      int64
	SecondsSeeding          time.Duration
	SeedIdleLimit           int64
	SeedIdleMode            int64
	SeedRatioLimit          float64
	SeedRatioMode           transmissionrpc.SeedRatioMode
	SizeWhenDone            cunits.Bits
	StartDate               time.Time
	Status                  transmissionrpc.TorrentStatus
	Trackers                []*transmissionrpc.Tracker
	TrackerStats            []*transmissionrpc.TrackerStats
	TotalSize               cunits.Bits
	TorrentFile             string
	UploadedEver            int64
	UploadLimit             int64
	UploadLimited           bool
	UploadRatio             float64
	Wanted                  []bool
	WebSeeds                []string
	WebSeedsSendingToUs     int64

	*StoredTorrentInfo
	// contains filtered or unexported fields
}

TransmissionTorrent is a generated, pointer-free, and less safe variant of transmissionrpc.Torrent to make using the expr package easier.

func ToTransmissionTorrent

func ToTransmissionTorrent(input transmissionrpc.Torrent, sonarrDropPaths map[string]bool) TransmissionTorrent

ToTransmissionTorrent converts the library struct to our generated struct.

func (TransmissionTorrent) AnnounceHostnames

func (t TransmissionTorrent) AnnounceHostnames() (hostnames []string)

AnnounceHostnames returns a list of tracker announce URL hostnames.

func (*TransmissionTorrent) GetOrCreateStored

func (t *TransmissionTorrent) GetOrCreateStored() *StoredTorrentInfo

GetOrCreateStored gets or creates StoredTorrent info.

func (TransmissionTorrent) Imported

func (t TransmissionTorrent) Imported() bool

Imported returns whether all downloaded files were imported

Jump to

Keyboard shortcuts

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