Documentation
¶
Index ¶
- func Migration001AddBaseData(tx *gorm.DB) error
- func RunMigrations(dbh *gorm.DB)
- type Episode
- type Handle
- func (h *Handle) AddShow(s *Show) error
- func (h *Handle) GetAllShows() ([]Show, error)
- func (h *Handle) GetEpisodeByID(episodeid int64) (*Episode, error)
- func (h *Handle) GetEpisodeByShowSeasonAndNumber(showid, season, number int64) (*Episode, error)
- func (h *Handle) GetLastPollTime(name string) time.Time
- func (h *Handle) GetQualityGroupFromStringOrDefault(name string) *quality.QualityGroup
- func (h *Handle) GetQualityGroups() ([]quality.QualityGroup, error)
- func (h *Handle) GetShowByAllNames(name string) (*Show, int64, error)
- func (h *Handle) GetShowByID(showID int64) (*Show, error)
- func (h *Handle) GetShowByIndexerAndID(indexer string, indexerID int64) (*Show, error)
- func (h *Handle) GetShowByName(name string) (*Show, error)
- func (h *Handle) GetShowByNameIgnoreCase(name string) (*Show, error)
- func (h *Handle) GetShowEpisodes(s *Show) ([]Episode, error)
- func (h *Handle) GetShowFromNameException(name string) (*Show, int64, error)
- func (h *Handle) NextAirdateForShow(dbshow *Show) *time.Time
- func (h *Handle) SaveEpisode(e *Episode) error
- func (h *Handle) SaveEpisodes(eps []*Episode) error
- func (h *Handle) SaveNameExceptions(source string, excepts []*NameException) error
- func (h *Handle) SaveShow(s *Show) error
- func (h *Handle) SetLastPollTime(name string) error
- type LastPollTime
- type NameException
- type Show
- type TestReporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Migration001AddBaseData ¶
Migration001AddBaseData adds the baseline quality groups.
func RunMigrations ¶
RunMigrations will run all migrations.
TODO: make this a little more sophisticated.
Types ¶
type Episode ¶
type Episode struct {
ID int64 `gorm:"column:id; primary_key:yes"`
Show Show
ShowId int64
Name string
Season int64
Episode int64
Description string
AirDate time.Time
HasNFO bool `gorm:"column:has_nfo"`
HasTBN bool `gorm:"column:has_tbn"`
Status types.EpisodeStatus
Quality quality.Quality
Location string
FileSize int64
ReleaseName string
SceneSeason int64
SceneEpisode int64
AbsoluteNumber int64
SceneAbsoluteNumber int64
Version int64
ReleaseGroup string
}
Episode represents an individual episode of a Show
func (*Episode) AirDateString ¶
AirDateString returns the episode's airdate as a YYYY-MM-DD date if set. Otherwise it returns the empty string.
func (*Episode) BeforeSave ¶
BeforeSave performs validation on the record before saving
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle controls access to the database and makes sure only one operation is in process at a time.
func NewDBHandle ¶
NewDBHandle creates a new DBHandle
dbPath: the path to the database to use. verbose: when true database accesses are logged to stdout writeUpdates: when true actually write to the databse (useful for testing)
func NewMemoryDBHandle ¶
NewMemoryDBHandle creates a new in memory database. Useful for testing.
func (*Handle) GetAllShows ¶
GetAllShows returns all shows in the database.
func (*Handle) GetEpisodeByID ¶
GetEpisodeByID returns an episode with the given ID or an error if it doesn't exist.
func (*Handle) GetEpisodeByShowSeasonAndNumber ¶
GetEpisodeByShowSeasonAndNumber does exactly what it says.
func (*Handle) GetLastPollTime ¶
GetLastPollTime returns the last time recorded for the given name. If there is no record it returns a zero value time.Time
func (*Handle) GetQualityGroupFromStringOrDefault ¶
func (h *Handle) GetQualityGroupFromStringOrDefault(name string) *quality.QualityGroup
GetQualityGroupFromStringOrDefault tries to find a matching QualityGroup with the given name. If that doesn't exist it returns the first one with the Default bit set. If _that_ fails it will return (and create inthe db) the hardcoded default.
func (*Handle) GetQualityGroups ¶
func (h *Handle) GetQualityGroups() ([]quality.QualityGroup, error)
GetQualityGroups returns all quality groups.
func (*Handle) GetShowByAllNames ¶
GetShowByAllNames tries to find a show that matches the given name using alternate spelling and associated show names from various SceneException providers.
It returns the Show, a season override if that given name maps to a particular season of the show (common for Anime) and an error if one occured.
func (*Handle) GetShowByID ¶
GetShowByID returs the show with the given ID or an error if it doesn't exist.
func (*Handle) GetShowByIndexerAndID ¶
GetShowByIndexerAndID returns the show with the given indexer and indexerid or an error if it doesn't exist.
func (*Handle) GetShowByName ¶
GetShowByName returns the show with the given name (and it's episodes) or an error if not found.
func (*Handle) GetShowByNameIgnoreCase ¶
GetShowByNameIgnoreCase returns the show with the given name (and it's episodes) or an error if not found.
func (*Handle) GetShowEpisodes ¶
GetShowEpisodes returns all of the given show's episodes
func (*Handle) GetShowFromNameException ¶
GetShowFromNameException will try to match (ignoring case) the given name to a known Name Exception. If found it will then try to match that to a Show by matching the indexer and indexerid.
func (*Handle) NextAirdateForShow ¶
NextAirdateForShow returns the date of the next episode for this show.
func (*Handle) SaveEpisode ¶
SaveEpisode saves the given episode to the database
func (*Handle) SaveEpisodes ¶
SaveEpisodes save the list of episodes to the database. This is done in a transaction which will be much faster if the number of episodes is large.
func (*Handle) SaveNameExceptions ¶
func (h *Handle) SaveNameExceptions(source string, excepts []*NameException) error
SaveNameExceptions saves all the given exceptions, totally replacing the exceptions for the given source.
func (*Handle) SetLastPollTime ¶
SetLastPollTime records the current time for the given name.
type LastPollTime ¶
LastPollTime stores the last time we polled a particular provider.
func (*LastPollTime) AfterFind ¶
func (s *LastPollTime) AfterFind() error
AfterFind updates all times to UTC because SQLite driver sets everything to local
type NameException ¶
type NameException struct {
ID int64
Source string
Indexer string
IndexerID int64
Name string
Season int64
CreatedAt time.Time
UpdatedAt time.Time
}
NameException stores alternate names of shows to use when parsing input files.
func (*NameException) BeforeSave ¶
func (e *NameException) BeforeSave() error
BeforeSave ensures that all fields are set to non default values.
type Show ¶
type Show struct {
ID int64 `gorm:"column:id; primary_key:yes"`
Name string `sql:"not null"`
Description string
Indexer string `sql:"not null"`
IndexerID int64 `gorm:"column:indexer_key"` // id to use when looking up with the indexer
Episodes []Episode
Location string // Location of Show on disk
Network string
Genre string // pipe seperated
Classification string
Runtime int64 // in minutes
QualityGroup quality.QualityGroup
QualityGroupID int64
Airs string // Hour of the day
Status string
FlattenFolders bool
Paused bool
StartYear int
AirByDate bool
Language string
Subtitles bool
ImdbID string
Sports bool
Anime bool
Scene bool
DefaultEpStatus types.EpisodeStatus
LastIndexerUpdate time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
Show is a TV Show
func LoadFixtures ¶
func LoadFixtures(t TestReporter, d *Handle) []Show
LoadFixtures adds a base set of Fixtures to the given database.
func (*Show) AfterFind ¶
AfterFind updates all times to UTC because SQLite driver sets everything to local
func (*Show) BeforeSave ¶
BeforeSave validates a show before writing it to the database
type TestReporter ¶
type TestReporter interface {
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
}
TestReporter is a shim interface so we don't need to include the testing package in the compiled binary