varroa

package module
Version: v0.0.0-...-f5faf1b Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 72 Imported by: 0

README

varroa

Varroa Musica

Documentation Go Report Card codecov Build status

A much nicer parasite than varroa destructor.

Documentation

Index

Constants

View Source
const (
	FullName       = "varroa musica"
	FullNameAlt    = "VarroaMusica"
	FullVersion    = "%s -- %s."
	DefaultPIDFile = "varroa_pid"
	DefaultLogFile = "log"

	// directories & files
	DefaultConfigurationFile = "config.yaml"

	StatsDir    = "stats"
	MetadataDir = "TrackerMetadata"

	OriginJSONFile = "origin.json"

	DefaultHistoryDB   = "history.db"
	DefaultDownloadsDB = "downloads.db"
	DefaultLibraryDB   = "library.db"

	// information
	InfoUserFilesArchived = "User files backed up."
	InfoUsage             = "Before running a command that requires the daemon, run 'varroa start'."
	InfoEncrypted         = "Configuration file encrypted. You can use this encrypted version in place of the unencrypted version."
	InfoDecrypted         = "Configuration file has been decrypted to a plaintext YAML file."

	// cli errors
	ErrorArguments        = "Error parsing command line arguments"
	ErrorInfoBadArguments = "Bad arguments"
	// daemon errors
	ErrorFindingDaemon          = "Error finding daemon"
	ErrorGettingDaemonContext   = "Error launching daemon (it probably is running already)"
	ErrorSendingCommandToDaemon = "Error sending command to daemon"
	// command check-log errors
	ErrorCheckingLog = "Error checking log"

	// command snatch errors
	ErrorSnatchingTorrent = "Error snatching torrent"
	// command info errors
	ErrorShowingTorrentInfo = "Error displaying torrent info"
	// command refresh-metadata errors
	ErrorRefreshingMetadata = "Error refreshing metadata"

	// command reseed
	ErrorReseed = "error trying to reseed release"

	ErrorSettingUp     = "Error setting up"
	ErrorLoadingConfig = "Error loading configuration"

	ErrorFindingMusicAndMetadata = "directory %s does not contain music files and tracker metadata"

	ErrorGeneratingGraphs = "Error generating graphs (may require more data, 24h worth for daily graphs)"
)
View Source
const (
	ReleaseString = `` /* 195-byte string literal not displayed */

	TorrentPath         = `%s - %s (%d) [%s %s %s %s] - %s.torrent`
	TorrentNotification = `%s - %s (%d) [%s/%s/%s/%s] [%s]`
)
View Source
const (
	CSSTemplate = `` /* 7091-byte string literal not displayed */

)

Variables

View Source
var DownloadFolderStates = []string{"unsorted", "UNUSED", "accepted", "rejected"}
View Source
var (
	// Version will be updated by the Makefile at build time.
	Version = "dev"
)

Functions

func ArchiveUserFiles

func ArchiveUserFiles() error

ArchiveUserFiles in a timestamped compressed archive.

func CheckLog

func CheckLog(t *tracker.Gazelle, logPaths []string) error

CheckLog on a tracker's logchecker

func ColorizeDownloadState

func ColorizeDownloadState(value int, txt string) string

func DirectoryContainsMusicAndMetadata

func DirectoryContainsMusicAndMetadata(directoryPath string) bool

DirectoryContainsMusicAndMetadata returns true if it contains mp3 or flac files, and JSONs in a TrackerMetadata folder.

func DownloadState

func DownloadState(txt string) int

func FuseMount

func FuseMount(path, mountpoint, dbPath string) error

func GenerateStats

func GenerateStats(e *Environment) error

GenerateStats for all labels and the associated HTML index.

func GetPassphrase

func GetPassphrase() (string, error)

func GoGoRoutines

func GoGoRoutines(e *Environment, noDaemon bool)

func HasSuffix

func HasSuffix(field, v string) q.Matcher

HasSuffix matches if the field value has the argument as suffix (subfolder)

func InSlice

func InSlice(field, v string) q.Matcher

InSlice matches if one element of a []string is equal to the argument

func IsValidDownloadState

func IsValidDownloadState(txt string) bool

func MatchAllInSlice

func MatchAllInSlice(a []string, b []string) bool

MatchAllInSlice checks if all strings in slice a are in slice b

func MatchInSlice

func MatchInSlice(a string, b []string) bool

MatchInSlice checks if a string regexp-matches a slice of patterns, returns bool

func Notify

func Notify(msg, tracker, msgType string, e *Environment) error

Notify in a goroutine, or directly.

func RefreshLibraryMetadata

func RefreshLibraryMetadata(path string, t *tracker.Gazelle, id string) error

RefreshLibraryMetadata for a list of releases on a tracker, using the given location instead of assuming they are in the download directory.

func RefreshMetadata

func RefreshMetadata(e *Environment, t *tracker.Gazelle, IDStrings []string) error

RefreshMetadata for a list of releases on a tracker

func ReorganizeLibrary

func ReorganizeLibrary(doNothing, interactive bool) error

ReorganizeLibrary using tracker metadata and the user-defined template

func Reseed

func Reseed(t *tracker.Gazelle, path []string) error

Reseed a release using local files and tracker metadata

func SavePassphraseForDaemon

func SavePassphraseForDaemon() ([]byte, error)

SavePassphraseForDaemon saves the encrypted configuration file passphrase to env if necessary. In the daemon, retrieves that passphrase.

func SendOrders

func SendOrders(command []byte) error

SendOrders from the CLI to the running daemon

func ShowTorrentInfo

func ShowTorrentInfo(e *Environment, t *tracker.Gazelle, IDStrings []string) error

ShowTorrentInfo of a list of releases on a tracker

func SnatchTorrents

func SnatchTorrents(e *Environment, t *tracker.Gazelle, IDStrings []string, useFLToken bool) error

SnatchTorrents on a tracker using their TorrentIDs

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack helps track the time taken by a function.

Types

type Config

type Config struct {
	General       *ConfigGeneral
	Trackers      []*ConfigTracker
	Autosnatch    []*ConfigAutosnatch
	Stats         []*ConfigStats
	WebServer     *ConfigWebServer
	Notifications *ConfigNotifications
	GitlabPages   *ConfigGitlabPages `yaml:"gitlab_pages"`
	Filters       []*ConfigFilter
	Library       *ConfigLibrary
	MPD           *ConfigMPD
	Metadata      *ConfigMetadata

	DownloadFolderConfigured bool
	LibraryConfigured        bool
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(path string) (*Config, error)

func (*Config) DecryptTo

func (c *Config) DecryptTo(file string, passphrase []byte) error

func (*Config) Encrypt

func (c *Config) Encrypt(file string, passphrase []byte) error

func (*Config) GetAutosnatch

func (c *Config) GetAutosnatch(label string) (*ConfigAutosnatch, error)

func (*Config) GetStats

func (c *Config) GetStats(label string) (*ConfigStats, error)

func (*Config) GetTracker

func (c *Config) GetTracker(label string) (*ConfigTracker, error)

func (*Config) Load

func (c *Config) Load(file string) error

func (*Config) LoadFromBytes

func (c *Config) LoadFromBytes(b []byte) error

func (*Config) String

func (c *Config) String() string

func (*Config) TrackerLabels

func (c *Config) TrackerLabels() []string

type ConfigAutosnatch

type ConfigAutosnatch struct {
	Tracker              string
	LocalAddress         string `yaml:"local_address"`
	IRCServer            string `yaml:"irc_server"`
	IRCKey               string `yaml:"irc_key"`
	IRCSSL               bool   `yaml:"irc_ssl"`
	IRCSSLSkipVerify     bool   `yaml:"irc_ssl_skip_verify"`
	NickservPassword     string `yaml:"nickserv_password"`
	BotName              string `yaml:"bot_name"`
	Announcer            string
	AnnounceChannel      string   `yaml:"announce_channel"`
	BlacklistedUploaders []string `yaml:"blacklisted_uploaders"`
	// contains filtered or unexported fields
}

func (*ConfigAutosnatch) String

func (ca *ConfigAutosnatch) String() string

type ConfigFilter

type ConfigFilter struct {
	Name                 string   `yaml:"name"`
	Artist               []string `yaml:"artist"`
	ExcludedArtist       []string `yaml:"excluded_artist"`
	Year                 []int    `yaml:"year"`
	YearRange            []string `yaml:"year_range"`
	EditionYear          []int    `yaml:"edition_year"`
	EditionYearRange     []string `yaml:"edition_year_range"`
	RecordLabel          []string `yaml:"record_label"`
	TagsIncluded         []string `yaml:"included_tags"`
	TagsExcluded         []string `yaml:"excluded_tags"`
	TagsRequired         []string `yaml:"required_tags"`
	ReleaseType          []string `yaml:"type"`
	ExcludedReleaseType  []string `yaml:"excluded_type"`
	Title                []string `yaml:"title"`
	Edition              []string `yaml:"edition"`
	Format               []string `yaml:"format"`
	Source               []string `yaml:"source"`
	Quality              []string `yaml:"quality"`
	HasCue               bool     `yaml:"has_cue"`
	HasLog               bool     `yaml:"has_log"`
	LogScore             int      `yaml:"log_score"`
	PerfectFlac          bool     `yaml:"perfect_flac"`
	AllowDuplicates      bool     `yaml:"allow_duplicates"`
	AllowScene           bool     `yaml:"allow_scene"`
	MinSizeMB            int      `yaml:"min_size_mb"`
	MaxSizeMB            int      `yaml:"max_size_mb"`
	WatchDir             string   `yaml:"watch_directory"`
	UniqueInGroup        bool     `yaml:"unique_in_group"`
	Tracker              []string `yaml:"tracker"`
	Uploader             []string `yaml:"uploader"`
	RejectUnknown        bool     `yaml:"reject_unknown_releases"`
	RejectTrumpable      bool     `yaml:"reject_trumpable_releases"`
	BlacklistedUploaders []string `yaml:"blacklisted_uploaders"`
}

func (*ConfigFilter) String

func (cf *ConfigFilter) String() string

type ConfigGeneral

type ConfigGeneral struct {
	LogLevel                   int    `yaml:"log_level"`
	WatchDir                   string `yaml:"watch_directory"`
	DownloadDir                string `yaml:"download_directory"`
	AutomaticMetadataRetrieval bool   `yaml:"automatic_metadata_retrieval"`
	FullMetadataRetrieval      bool   `yaml:"full_metadata_retrieval"`
	TimestampedLogs            bool   `yaml:"timestamped_logs"`
}

func (*ConfigGeneral) String

func (cg *ConfigGeneral) String() string

String representation for ConfigGeneral.

type ConfigGitlabPages

type ConfigGitlabPages struct {
	GitHTTPS string `yaml:"git_https"`
	User     string
	Password string
	URL      string
	Folder   string
}

func (*ConfigGitlabPages) String

func (cg *ConfigGitlabPages) String() string

type ConfigIRC

type ConfigIRC struct {
	Tracker string
	User    string
}

func (*ConfigIRC) String

func (ci *ConfigIRC) String() string

type ConfigLibrary

type ConfigLibrary struct {
	Directory         string              `yaml:"directory"`
	UseHardLinks      bool                `yaml:"use_hard_links"`
	MoveSorted        bool                `yaml:"move_sorted"`
	AutomaticMode     bool                `yaml:"automatic_mode"`
	Template          string              `yaml:"folder_template"`
	AdditionalSources []string            `yaml:"additional_source_directories"`
	AliasesFile       string              `yaml:"aliases_file"`
	Aliases           map[string][]string `yaml:"-"`
	CategoriesFile    string              `yaml:"categories_file"`
	Categories        map[string][]string `yaml:"-"`
	PlaylistDirectory string              `yaml:"playlist_directory"`
}

func (*ConfigLibrary) String

func (cl *ConfigLibrary) String() string

type ConfigMPD

type ConfigMPD struct {
	Server   string
	Password string
	Library  string
}

func (*ConfigMPD) String

func (cm *ConfigMPD) String() string

type ConfigMetadata

type ConfigMetadata struct {
	DiscogsToken string `yaml:"discogs_token"`
}

func (*ConfigMetadata) String

func (cm *ConfigMetadata) String() string

type ConfigNotifications

type ConfigNotifications struct {
	Pushover *ConfigPushover
	WebHooks *WebHooksConfig
	Irc      *ConfigIRC
}

type ConfigPushover

type ConfigPushover struct {
	User               string
	Token              string
	IncludeBufferGraph bool `yaml:"include_buffer_graph"`
}

func (*ConfigPushover) String

func (cp *ConfigPushover) String() string

type ConfigStats

type ConfigStats struct {
	Tracker             string
	UpdatePeriodH       int     `yaml:"update_period_hour"`
	MaxBufferDecreaseMB int     `yaml:"max_buffer_decrease_by_period_mb"`
	MinimumRatio        float64 `yaml:"min_ratio"`
	TargetRatio         float64 `yaml:"target_ratio"`
}

func (*ConfigStats) String

func (cs *ConfigStats) String() string

type ConfigTracker

type ConfigTracker struct {
	Name     string
	User     string
	Password string
	Cookie   string
	APIKey   string `yaml:"api_key"`
	URL      string
}

func (*ConfigTracker) String

func (ct *ConfigTracker) String() string

type ConfigWebServer

type ConfigWebServer struct {
	ServeMetadata  bool   `yaml:"serve_metadata"`
	ServeStats     bool   `yaml:"serve_stats"`
	Theme          string `yaml:"theme"`
	User           string `yaml:"stats_user"`
	Password       string `yaml:"stats_password"`
	AllowDownloads bool   `yaml:"allow_downloads"`
	Token          string `yaml:"token"`
	PortHTTP       int    `yaml:"http_port"`
	PortHTTPS      int    `yaml:"https_port"`
	Hostname       string `yaml:"https_hostname"`
}

func (*ConfigWebServer) String

func (cw *ConfigWebServer) String() string

type Database

type Database struct {
	DB *storm.DB
	// contains filtered or unexported fields
}

Database allows manipulating stats or release entries.

func NewDatabase

func NewDatabase(path string) (*Database, error)

NewDatabase opens the Database.

func (*Database) Close

func (db *Database) Close() error

Close the Database

func (*Database) Open

func (db *Database) Open(path string) error

Open the Database

type DownloadEntry

type DownloadEntry struct {
	ID                 int      `storm:"id,increment"`
	FolderName         string   `storm:"unique"`
	State              int      `storm:"index"`
	Tracker            []string `storm:"index"`
	TrackerID          []int    `storm:"index"`
	Artists            []string `storm:"index"`
	HasTrackerMetadata bool     `storm:"index"`
	SchemaVersion      int
}

func (*DownloadEntry) Description

func (d *DownloadEntry) Description(root string) string

func (*DownloadEntry) Load

func (d *DownloadEntry) Load(root string) error

func (*DownloadEntry) RawShortString

func (d *DownloadEntry) RawShortString() string

func (*DownloadEntry) ShortState

func (d *DownloadEntry) ShortState() string

func (*DownloadEntry) ShortString

func (d *DownloadEntry) ShortString() string

func (*DownloadEntry) Sort

func (d *DownloadEntry) Sort(e *Environment, root string) error

func (*DownloadEntry) String

func (d *DownloadEntry) String() string

type DownloadsDB

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

func NewDownloadsDB

func NewDownloadsDB(path, root string, additionalSources []string) (*DownloadsDB, error)

func (*DownloadsDB) Clean

func (d *DownloadsDB) Clean() error

func (*DownloadsDB) Close

func (d *DownloadsDB) Close() error

func (*DownloadsDB) FindByArtist

func (d *DownloadsDB) FindByArtist(artist string) []DownloadEntry

func (*DownloadsDB) FindByFolderName

func (d *DownloadsDB) FindByFolderName(folderName string) (DownloadEntry, error)

func (*DownloadsDB) FindByID

func (d *DownloadsDB) FindByID(id int) (DownloadEntry, error)

func (*DownloadsDB) FindByState

func (d *DownloadsDB) FindByState(state string) []DownloadEntry

func (*DownloadsDB) RescanIDs

func (d *DownloadsDB) RescanIDs(IDs []int) error

func (*DownloadsDB) RescanPath

func (d *DownloadsDB) RescanPath(folderName string) error

func (*DownloadsDB) Scan

func (d *DownloadsDB) Scan() error

func (*DownloadsDB) Sort

func (d *DownloadsDB) Sort(e *Environment) error

func (*DownloadsDB) SortThisID

func (d *DownloadsDB) SortThisID(e *Environment, id int, ignoreSorted bool) error

func (*DownloadsDB) String

func (d *DownloadsDB) String() string

type Environment

type Environment struct {
	Trackers map[string]*tracker.Gazelle
	// contains filtered or unexported fields
}

Environment keeps track of all the context varroa needs.

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment prepares a new Environment.

func (*Environment) DeployToGitlabPages

func (e *Environment) DeployToGitlabPages() error

DeployToGitlabPages with git wrapper

func (*Environment) GenerateIndex

func (e *Environment) GenerateIndex() error

func (*Environment) LoadConfiguration

func (e *Environment) LoadConfiguration() error

LoadConfiguration whether the configuration file is encrypted or not.

func (*Environment) SetConfig

func (e *Environment) SetConfig(c *Config)

func (*Environment) SetUp

func (e *Environment) SetUp(autologin bool) error

SetUp the Environment

func (*Environment) Tracker

func (e *Environment) Tracker(label string) (*tracker.Gazelle, error)

type FS

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

func (*FS) Root

func (f *FS) Root() (fs.Node, error)

func (*FS) Statfs

func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error

type FuseDB

type FuseDB struct {
	Database
	Root string
}

func (*FuseDB) Scan

func (fdb *FuseDB) Scan(rootPath string) error

type FuseDir

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

FuseDir is a folder in the FUSE filesystem. Top directory == exposed categories, such as artists, tags. ex: artists/Radiohead/OK Computer/FILES

func (*FuseDir) Attr

func (d *FuseDir) Attr(ctx context.Context, a *fuse.Attr) error

func (*FuseDir) Lookup

func (d *FuseDir) Lookup(ctx context.Context, name string) (fs.Node, error)

func (*FuseDir) ReadDirAll

func (d *FuseDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error)

ReadDirAll returns directory entries for the FUSE filesystem

func (*FuseDir) String

func (d *FuseDir) String() string

type FuseEntry

type FuseEntry struct {
	ID          int      `storm:"id,increment"`
	FolderName  string   `storm:"unique"`
	Artists     []string `storm:"index"`
	Tags        []string `storm:"index"`
	Title       string   `storm:"index"`
	Year        int      `storm:"index"`
	Tracker     []string `storm:"index"`
	RecordLabel string   `storm:"index"`
	Source      string   `storm:"index"`
	Format      string   `storm:"index"`
}

FuseEntry is the struct describing a release folder with tracker metadata. Only the FolderName is indexed.

func (*FuseEntry) Load

func (fe *FuseEntry) Load(root string) error

type FuseFile

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

func (*FuseFile) Attr

func (f *FuseFile) Attr(ctx context.Context, a *fuse.Attr) error

func (*FuseFile) Open

func (f *FuseFile) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error)

func (*FuseFile) String

func (f *FuseFile) String() string

type FuseFileHandle

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

func (*FuseFileHandle) Flush

func (fh *FuseFileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error

func (*FuseFileHandle) Read

func (fh *FuseFileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error

func (*FuseFileHandle) Release

func (fh *FuseFileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) error

type FusePath

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

FusePath holds all of the informations to generate a FUSE path.

func (*FusePath) Category

func (d *FusePath) Category() string

func (*FusePath) SetCategory

func (d *FusePath) SetCategory(value string) error

func (*FusePath) String

func (d *FusePath) String() string

type HTMLIndex

type HTMLIndex struct {
	Title         string
	Time          string
	Version       string
	Stats         []HTMLStats
	CSS           template.CSS
	Script        string
	ShowDownloads bool
	Downloads     []DownloadEntry
	DownloadInfo  template.HTML
	MainContent   template.HTML
	URLFolder     string
}

HTMLIndex provides data for the htmlIndexTemplate.

func (*HTMLIndex) IndexDownloadsInfo

func (hi *HTMLIndex) IndexDownloadsInfo() ([]byte, error)

func (*HTMLIndex) IndexDownloadsList

func (hi *HTMLIndex) IndexDownloadsList() ([]byte, error)

func (*HTMLIndex) IndexStats

func (hi *HTMLIndex) IndexStats() ([]byte, error)

IndexStats executes the template and save the result to a file.

func (*HTMLIndex) MainPage

func (hi *HTMLIndex) MainPage() ([]byte, error)

func (*HTMLIndex) SetMainContentDownloadsInfo

func (hi *HTMLIndex) SetMainContentDownloadsInfo() error

func (*HTMLIndex) SetMainContentDownloadsList

func (hi *HTMLIndex) SetMainContentDownloadsList() error

func (*HTMLIndex) SetMainContentStats

func (hi *HTMLIndex) SetMainContentStats() error
type HTMLLink struct {
	Name  string
	URL   string
	Title string
}

HTMLLink represents a link.

type HTMLStats

type HTMLStats struct {
	Name         string
	TrackerStats [][]string
	GraphLinks   []HTMLLink
	Graphs       []HTMLLink
}

HTMLStats has all the information for a tracker: stats and graphs.

type HistoryTheme

type HistoryTheme struct {
	GraphTransparentBackground bool
	GraphColor                 string
	GraphFillerOpacity         uint8
	GraphAxisColor             string
	IndexBackgroundColor       string
	IndexFontColor             string
	IndexMenuColor             string
	IndexMenuLinkColor         string
	IndexMenuBackgroundColor   string
	IndexMenuHeaderColor       string
}

func (HistoryTheme) CSS

func (ht HistoryTheme) CSS() template.CSS

type IncomingJSON

type IncomingJSON struct {
	Token   string
	Command string
	Args    []string
	FLToken bool
	Site    string
}

IncomingJSON from the websocket created by the GM script, also used with unix socket.

type MPD

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

func (*MPD) Add

func (m *MPD) Add(path string) error

Add path (relative to mpd library root) of thing to play

func (*MPD) Clear

func (m *MPD) Clear() error

Clear playlist

func (*MPD) Close

func (m *MPD) Close() error

Close the connection to the server

func (*MPD) Connect

func (m *MPD) Connect(c *ConfigMPD) error

Connect to MPD server

func (*MPD) Disable

func (m *MPD) Disable(path string) error

Disable the varroa MPD subdir This removes the symlink inside the MPD library

func (*MPD) DisableAndDisconnect

func (m *MPD) DisableAndDisconnect(dlFolder, release string) error

func (*MPD) Enable

func (m *MPD) Enable(path string) error

Enable a path outside of MPD library This adds the symlink inside the MPD library to the specified path

func (*MPD) IsRunning

func (m *MPD) IsRunning() bool

IsRunning checks for an active MPD daemon

func (*MPD) Play

func (m *MPD) Play() error

Play at current position

func (*MPD) SendAndPlay

func (m *MPD) SendAndPlay(dlFolder, release string) error

func (*MPD) Stop

func (m *MPD) Stop() error

Stop playing music

func (*MPD) Update

func (m *MPD) Update() error

Update the MPD database for the varroa MPD subdir

type Notification

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

func (*Notification) Send

func (n *Notification) Send(message string, addLink bool, link, pngLink string) error

type OriginJSON

type OriginJSON struct {
	Tracker             string `json:"tracker"`
	ID                  int    `json:"id"`
	GroupID             int    `json:"group_id"`
	TimeSnatched        int64  `json:"time_snatched"`
	LastUpdatedMetadata int64  `json:"last_updated"`
	IsAlive             bool   `json:"is_alive"`
}

type OutgoingJSON

type OutgoingJSON struct {
	Status  int
	Target  int
	Message string
}

OutgoingJSON to the websocket created by the GM script.

type Release

type Release struct {
	ID          uint32 `storm:"id,increment"`
	Tracker     string `storm:"index"`
	Timestamp   time.Time
	TorrentID   string `storm:"index"`
	GroupID     string
	Artists     []string
	Title       string
	Year        int
	ReleaseType string
	Format      string
	Quality     string
	HasLog      bool
	LogScore    int
	HasCue      bool
	IsScene     bool
	Source      string
	Tags        []string

	Size   uint64
	Folder string
	Filter string
	// contains filtered or unexported fields
}

func NewRelease

func NewRelease(trackerName string, parts []string, alternative bool) (*Release, error)

func (*Release) HasCompatibleTrackerInfo

func (r *Release) HasCompatibleTrackerInfo(filter *ConfigFilter, blacklistedUploaders []string, info *TrackerMetadata) bool

func (*Release) IsMusicRelease

func (r *Release) IsMusicRelease() bool

IsMusicRelease returns false if the release has no artists

func (*Release) Satisfies

func (r *Release) Satisfies(filter *ConfigFilter) bool

func (*Release) ShortString

func (r *Release) ShortString() string

func (*Release) String

func (r *Release) String() string

func (*Release) TorrentFile

func (r *Release) TorrentFile() string

type ServerPage

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

func (*ServerPage) DownloadsInfo

func (sc *ServerPage) DownloadsInfo(e *Environment, downloads *DownloadsDB, id string) ([]byte, error)

func (*ServerPage) DownloadsList

func (sc *ServerPage) DownloadsList(downloads *DownloadsDB) ([]byte, error)

func (*ServerPage) Index

func (sc *ServerPage) Index(downloads *DownloadsDB) ([]byte, error)

func (*ServerPage) SaveIndex

func (sc *ServerPage) SaveIndex(e *Environment, file string) error

SaveIndex is only used for Gitlab pages, so it never shows Downloads and will need to know the repository name (ie Pages subfolder).

type SnatchStatsEntry

type SnatchStatsEntry struct {
	ID           uint32 `storm:"id,increment"`
	Tracker      string `storm:"index"`
	Size         uint64
	Number       int
	Timestamp    time.Time `storm:"index"`
	Collected    bool      `storm:"index"`
	StartOfDay   bool      `storm:"index"`
	StartOfWeek  bool      `storm:"index"`
	StartOfMonth bool      `storm:"index"`
}

type SnatchStatsSeries

type SnatchStatsSeries struct {
	Tracker string
	Time    []time.Time
	Number  []float64
	Size    []float64
}

SnatchStatsSeries is a struct that holds the SnatchStats data needed to generate time series graphs. It can then draw and save the graphs (for raw stats or stats/time unit)

func (*SnatchStatsSeries) AddStats

func (sss *SnatchStatsSeries) AddStats(entries ...SnatchStatsEntry)

AddStats for all entries or a selection to get the correct timeseries

func (*SnatchStatsSeries) GenerateGraphs

func (sss *SnatchStatsSeries) GenerateGraphs(directory, prefix string, firstTimestamp time.Time, addSMA bool) error

GenerateGraphs: time series graphs for size, number

type StatsDB

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

func NewStatsDB

func NewStatsDB(path string) (*StatsDB, error)

func (*StatsDB) AddSnatch

func (sdb *StatsDB) AddSnatch(release Release) error

func (*StatsDB) AlreadySnatchedDuplicate

func (sdb *StatsDB) AlreadySnatchedDuplicate(release *Release) bool

func (*StatsDB) AlreadySnatchedFromGroup

func (sdb *StatsDB) AlreadySnatchedFromGroup(release *Release) bool

func (*StatsDB) FilterByTracker

func (sdb *StatsDB) FilterByTracker(tracker string, statsType string) ([]StatsEntry, error)

func (*StatsDB) GenerateAllGraphsForTracker

func (sdb *StatsDB) GenerateAllGraphsForTracker(tracker string) error

func (*StatsDB) GetLastCollected

func (sdb *StatsDB) GetLastCollected(tracker string, limit int) ([]StatsEntry, error)

func (*StatsDB) Save

func (sdb *StatsDB) Save(entry *StatsEntry) error

func (*StatsDB) Update

func (sdb *StatsDB) Update() error

Update needs to be called everyday at midnight (add cron job) It creates StatsEntries for each start of day (which might also be start of week/month) That way, it'll be quicker to create stats and recalculate StatsDeltas.

type StatsDelta

type StatsDelta struct {
	Tracker       string
	Timestamp     time.Time
	Up            int64
	Down          int64
	Ratio         float64
	Buffer        int64
	WarningBuffer int64
}

func CalculateDelta

func CalculateDelta(first, second StatsEntry) (*StatsDelta, error)

func CalculateDeltas

func CalculateDeltas(entries []StatsEntry) []StatsDelta

type StatsEntry

type StatsEntry struct {
	ID            uint32 `storm:"id,increment"`
	Tracker       string `storm:"index"`
	Up            uint64
	Down          uint64
	Ratio         float64
	Timestamp     time.Time
	TimestampUnix int64 `storm:"index"`
	Collected     bool  `storm:"index"`
	StartOfDay    bool  `storm:"index"`
	StartOfWeek   bool  `storm:"index"`
	StartOfMonth  bool  `storm:"index"`
	SchemaVersion int
}

func InterpolateStats

func InterpolateStats(previous, next StatsEntry, targetTime time.Time) (*StatsEntry, error)

func NewStatsEntry

func NewStatsEntry(gazelleTracker *tracker.Gazelle, gzStats *tracker.GazelleUserStats) (*StatsEntry, error)

func (*StatsEntry) Diff

func (se *StatsEntry) Diff(previous *StatsEntry) (int64, int64, int64, int64, float64)

TODO REPLACE BY A DELTA

func (*StatsEntry) IsProgressAcceptable

func (se *StatsEntry) IsProgressAcceptable(previous *StatsEntry, maxDecrease int, minimumRatio float64) bool

func (*StatsEntry) Progress

func (se *StatsEntry) Progress(previous *StatsEntry) string

func (*StatsEntry) ProgressParts

func (se *StatsEntry) ProgressParts(previous *StatsEntry) []string

TODO do something about this awful thing

func (*StatsEntry) String

func (se *StatsEntry) String() string

func (*StatsEntry) ToSlice

func (se *StatsEntry) ToSlice() []string

TODO reimplement export to CSV

type StatsSeries

type StatsSeries struct {
	Tracker       string
	Time          []time.Time
	Up            []float64
	Down          []float64
	Ratio         []float64
	Buffer        []float64
	WarningBuffer []float64
}

StatsSeries is a struct that holds the Stats data needed to generate time series graphs. It can then draw and save the graphs (for raw stats or stats/time unit)

func (*StatsSeries) AddDeltas

func (ss *StatsSeries) AddDeltas(entries ...StatsDelta) error

AddDeltas accumulates the data from a selection of StatsDeltas

func (*StatsSeries) AddStats

func (ss *StatsSeries) AddStats(entries ...StatsEntry) error

AddStats for all entries or a selection to get the correct timeseries

func (*StatsSeries) GenerateGraphs

func (ss *StatsSeries) GenerateGraphs(directory, prefix string, firstTimestamp time.Time, addSMA bool) error

GenerateGraphs: time series graphs for up, down, ratio, buffer, warningbuffer

type TrackerMetadata

type TrackerMetadata struct {
	// JSONs
	ReleaseJSON []byte `json:"-"`
	OriginJSON  []byte `json:"-"`
	// tracker related metadata
	ID           int
	GroupID      int
	Tracker      string
	TrackerURL   string
	ReleaseURL   string
	TimeSnatched int64
	LastUpdated  int64
	IsAlive      bool
	Size         uint64
	Uploader     string
	FolderName   string
	CoverURL     string

	// release related metadata
	Artists       []TrackerMetadataArtist
	Title         string
	Tags          []string
	ReleaseType   string
	RecordLabel   string
	CatalogNumber string
	OriginalYear  int
	EditionName   string
	EditionYear   int
	Source        string
	SourceFull    string
	Format        string
	Quality       string
	LogScore      int
	HasLog        bool
	HasCue        bool
	IsScene       bool
	// for library organization
	MainArtist      string
	MainArtistAlias string
	Category        string
	// contents
	Tracks      []TrackerMetadataTrack
	TotalTime   string
	Lineage     []TrackerMetadataLineage
	Description string
	// current tracker state
	CurrentSeeders int  `json:"-"`
	Reported       bool `json:"-"`
	Trumpable      bool `json:"-"`
	ApprovedLossy  bool `json:"-"`
}

func (*TrackerMetadata) GeneratePath

func (tm *TrackerMetadata) GeneratePath(folderTemplate, releaseFolder string) string

func (*TrackerMetadata) HTMLDescription

func (tm *TrackerMetadata) HTMLDescription() string

func (*TrackerMetadata) IsWellSeeded

func (tm *TrackerMetadata) IsWellSeeded() bool

IsWellSeeded if it has more than minimumSeeders.

func (*TrackerMetadata) Load

func (*TrackerMetadata) LoadFromID

func (tm *TrackerMetadata) LoadFromID(t *tracker.Gazelle, id string) error

LoadFromID directly from tracker

func (*TrackerMetadata) LoadFromJSON

func (tm *TrackerMetadata) LoadFromJSON(tracker string, originJSON, releaseJSON string) error

func (*TrackerMetadata) LoadUserJSON

func (tm *TrackerMetadata) LoadUserJSON(parentFolder string) error

func (*TrackerMetadata) Release

func (tm *TrackerMetadata) Release() *Release

func (*TrackerMetadata) SaveCover

func (tm *TrackerMetadata) SaveCover(releaseFolder string) error

func (*TrackerMetadata) SaveFromTracker

func (tm *TrackerMetadata) SaveFromTracker(parentFolder string, t *tracker.Gazelle) error

SaveFromTracker all of the relevant metadata.

func (*TrackerMetadata) TextDescription

func (tm *TrackerMetadata) TextDescription(fancy bool) string

func (*TrackerMetadata) UpdateUserJSON

func (tm *TrackerMetadata) UpdateUserJSON(destination, mainArtist, mainArtistAlias, category string) error

func (*TrackerMetadata) WriteUserJSON

func (tm *TrackerMetadata) WriteUserJSON(destination string) error

type TrackerMetadataArtist

type TrackerMetadataArtist struct {
	ID   int
	Name string
	Role string
	JSON []byte `json:"-"`
}

type TrackerMetadataLineage

type TrackerMetadataLineage struct {
	Source            string
	LinkOrDescription string
}

type TrackerMetadataTrack

type TrackerMetadataTrack struct {
	Disc     string
	Number   string
	Title    string
	Duration string
	Size     string
}

func (*TrackerMetadataTrack) String

func (rit *TrackerMetadataTrack) String() string

type TrackerOriginJSON

type TrackerOriginJSON struct {
	Path    string                 `json:"-"`
	Origins map[string]*OriginJSON `json:"known_origins"`
}

TrackerOriginJSON contains the list of trackers of origin for a release.

func (*TrackerOriginJSON) Load

func (toc *TrackerOriginJSON) Load() error

type WebHookJSON

type WebHookJSON struct {
	Site    string
	Message string
	Type    string // "error" "info"
	Link    string
}

func (*WebHookJSON) Send

func (whj *WebHookJSON) Send(address string, token string) error

type WebHooksConfig

type WebHooksConfig struct {
	Address  string
	Token    string
	Trackers []string
}

func (*WebHooksConfig) String

func (whc *WebHooksConfig) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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