internal

package
v0.0.0-...-c60cb76 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const JobSyncInterval time.Duration = 1 // Job syncs with config in every 1 hours
View Source
const StatusFileName string = "status.yaml"

Variables

Functions

func Base64Decode

func Base64Decode(encodedData string) (string, error)

func Base64Encode

func Base64Encode(decodedData string) string

func CreateTagInRadarr

func CreateTagInRadarr(tagLabel string) (*int, error)

func DeleteExpiredMovies

func DeleteExpiredMovies(moviesdata []byte, moviesIgnored []string, nextMaintenanceCycle time.Time, isDryRun bool) ([]string, error)

func GetMovieAge

func GetMovieAge(movie Movie) (*float64, error)

func GetMoviesData

func GetMoviesData() ([]byte, error)

func GetMoviesIgnored

func GetMoviesIgnored(ignoreTagId int, moviesdata []byte) ([]string, error)

func GetTagIdFromRadarr

func GetTagIdFromRadarr(tagLabel string) (*int, error)

func InitializeConfig

func InitializeConfig(configFile string) error

func InitializeStatus

func InitializeStatus(statusFile string) error

func Job

func Job(statusFile string, isDryRun bool) error

func MaintenanceCycleInInt

func MaintenanceCycleInInt(period Interval) int

func MarkMoviesForDeletion

func MarkMoviesForDeletion(moviesdata []byte, moviesIgnored []string, nextMaintenanceCycle time.Time, isDryRun bool) ([]string, error)

func SendEmailNotification

func SendEmailNotification(subject, body string) error

func SendGotifyNotification

func SendGotifyNotification(title, body string) error

func SendTelegramNotification

func SendTelegramNotification(body string) error

func UpdateStatusFile

func UpdateStatusFile(lastMaintenanceDate string, deletedMovies, ignoredMovies, moviesMarkedForDeletion []string, statusFile string) error

Types

type Configuration

type Configuration struct {
	MaintenanceCycle    Interval            `yaml:"maintenanceCycle"`
	DeleteAfterDays     int                 `yaml:"deleteAfterDays"`
	IgnoreTag           string              `yaml:"ignoreTag"`
	NotificationChannel NotificationChannel `yaml:"notificationChannel"`
	Radarr              RadarrConfig        `yaml:"radarr"`
	Sonarr              SonarrConfig        `yaml:"sonarr"`
}
var Config Configuration = Configuration{
	MaintenanceCycle: Daily,
	DeleteAfterDays:  90,
	IgnoreTag:        "cma-donotdelete",
	NotificationChannel: NotificationChannel{
		SMTP: SMTPConfig{
			Enabled:     false,
			Server:      "smtp.gmail.com",
			Port:        587,
			Security:    TLS,
			Username:    "example@gmail.com",
			B64Password: "dGgxc2lzbjB0QSQzY3IzdAo=",
			FromEmail:   "example@gmail.com",
			ToEmail:     []string{"alert@example.com"},
			CcEmail:     []string{""},
			BccEmail:    []string{""},
		},
		Gotify: GotifyConfig{
			Enabled:     false,
			URL:         "gotify.local",
			B64AppToken: "dGgxc2lzbjB0QSQzY3IzdAo=",
			Priority:    5,
		},
		Telegram: TelegramConfig{
			Enabled:     false,
			B64BotToken: "dGhpc2lzbm90YWJvdHRva2VuCg==",
			ChatId:      "000000000",
		},
	},
	Radarr: RadarrConfig{
		Enabled:      false,
		URL:          "http://radarr:7878",
		B64APIKey:    "dGhpc2lzbm90YW5hcGlrZXkK",
		Notification: false,
	},

	Sonarr: SonarrConfig{
		Enabled:      false,
		URL:          "http://sonarr:8989",
		B64APIKey:    "dGhpc2lzbm90YW5hcGlrZXkK",
		Notification: false,
	},
}

Default configurations

func ReadConfig

func ReadConfig(configFile string) (*Configuration, error)

type GotifyConfig

type GotifyConfig struct {
	Enabled     bool   `yaml:"enabled"`
	URL         string `yaml:"url"`
	B64AppToken string `yaml:"b64AppToken"`
	Priority    int    `yaml:"priority"`
}

type Interval

type Interval string
const (
	Daily      Interval = "daily"
	Every3Days Interval = "every3days"
	Weekly     Interval = "weekly"
	Bimonthly  Interval = "bimonthly"
	Monthly    Interval = "monthly"
)

type Movie

type Movie struct {
	Title     string          `json:"title"`
	HasFile   bool            `json:"hasFile"`
	Tags      []int           `json:"tags"`
	ID        int             `json:"id"`
	MovieFile MovieFileDetail `json:"movieFile"`
}

type MovieFileDetail

type MovieFileDetail struct {
	MovieId     int    `json:"movieId"`
	MovieFileId int    `json:"id"`
	Size        int    `json:"size"`
	DateAdded   string `json:"dateAdded"`
}

type MovieImportEvent

type MovieImportEvent struct {
	MovieId int    `json:"movieId"`
	Date    string `json:"date"`
}

func GetMovieImportEvents

func GetMovieImportEvents(movieId int) ([]MovieImportEvent, error)

type NotificationChannel

type NotificationChannel struct {
	SMTP     SMTPConfig
	Gotify   GotifyConfig
	Telegram TelegramConfig
}

type RadarrConfig

type RadarrConfig struct {
	Enabled      bool   `yaml:"enabled"`
	URL          string `yaml:"url"`
	B64APIKey    string `yaml:"b64ApiKey"`
	Notification bool   `yaml:"notification"`
}

type SMTPConfig

type SMTPConfig struct {
	Enabled     bool     `yaml:"enabled"`
	Server      string   `yaml:"server"`
	Port        int      `yaml:"port"`
	Security    Security `yaml:"security"`
	Username    string   `yaml:"username"`
	B64Password string   `yaml:"b64Password"`
	FromEmail   string   `yaml:"fromEmail"`
	ToEmail     []string `yaml:"toEmail"`
	CcEmail     []string `yaml:"ccEmail"`
	BccEmail    []string `yaml:"bccEmail"`
}

type Security

type Security string
const (
	None Security = "none"
	TLS  Security = "tls"
)

type SonarrConfig

type SonarrConfig struct {
	Enabled      bool   `yaml:"enabled"`
	URL          string `yaml:"url"`
	B64APIKey    string `yaml:"b64ApiKey"`
	Notification bool   `yaml:"notification"`
}

type Status

type Status struct {
	LastMaintenanceDate     string   `yaml:"lastMaintenanceDate"`
	NextMaintenanceDate     string   `yaml:"nextMaintenanceDate"`
	DeletedMovies           []string `yaml:"deletedMovies"`
	DeletedShows            []string `yaml:"deletedShows"`
	IgnoredMovies           []string `yaml:"ignoredMovies"`
	IgnoredShows            []string `yaml:"ignoredShows"`
	MoviesMarkedForDeletion []string `yaml:"moviesMarkedForDeletion"`
	ShowsMarkedForDeletion  []string `yaml:"showsMarkedForDeletion"`
}
var State Status

func ReadStatus

func ReadStatus(statusFile string) (*Status, error)

type Tag

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

type TelegramConfig

type TelegramConfig struct {
	Enabled     bool   `yaml:"enabled"`
	B64BotToken string `yaml:"b64BotToken"`
	ChatId      string `yaml:"chatId"`
}

Jump to

Keyboard shortcuts

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