library

package
v0.0.0-...-30262a5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package library is an SQL-based movie library which supports Movies, Series and Episodes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JustShows

func JustShows(showsWithFiles <-chan ShowWithFile) chan *Show

JustShows extracts just the shows from a ShowWithFile channel

Types

type CommonData

type CommonData struct {
	ImdbID      int                   `json:"imdb_id",sql:"unique"`
	Title       string                `json:"title"`
	Year        int                   `json:"year"`
	OtherTitles types.MapStringString `gorm:"type:blob",json:"other_titles"`
	Duration    types.Duration        `gorm:"type:integer",json:"duration"`
	Plot        string                `json:"plot"`
	PlotMedium  string                `json:"plot_medium"`
	PlotLong    string                `json:"plot_long"`
	PosterURL   string                `json:"poster_url"`
	ImdbRating  float32               `json:"imdb_rating"`
	ImdbVotes   int                   `json:"imdb_votes"`
	Languages   types.Languages       `gorm:"type:text",json:"languages"`

	ImdbError *string `json:"imdb_error"`
}

CommonData contains fields shared by movies, episodes and series

type EpisodeData

type EpisodeData struct {
	Season   int `json:"season"`
	Episode  int `json:"episode"`
	SeriesID uint
}

EpisodeData contains episode-specific keys

type Library

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

Library is a searchable library of movies, series and episodes

func New

func New(dbDriver string, arguments ...interface{}) (*Library, error)

New creates a library connected to the specified database

func (*Library) GetFileByPath

func (lib *Library) GetFileByPath(path string) (*VideoFile, error)

GetFileByPath finds the file by its path, creating it if it doesn't exist

func (*Library) GetSeriesByEpisode

func (lib *Library) GetSeriesByEpisode(episode *Show) (*Series, error)

GetSeriesByEpisode returns the series this show belongs to (if it's an episode) or nil otherwise

func (*Library) GetSeriesByImdbID

func (lib *Library) GetSeriesByImdbID(id int) (*Series, error)

GetSeriesByImdbID finds the series by its imdb id, creating it if it doesn't exist

func (*Library) GetShowByImdbID

func (lib *Library) GetShowByImdbID(id int) (*Show, error)

GetShowByImdbID finds the show by its imdb id, creating it if it doesn't exist

func (*Library) GetSubtitleByFilename

func (lib *Library) GetSubtitleByFilename(filename string) (*Subtitle, error)

GetSubtitleByFilename finds the subtitle by its filename, creating it if it doesn't exist

func (*Library) GetSubtitleByHash

func (lib *Library) GetSubtitleByHash(hash string) (*Subtitle, error)

GetSubtitleByHash finds the subtitle by its hash, creating it if it doesn't exist

func (*Library) HasFileWithPath

func (lib *Library) HasFileWithPath(path string) (bool, error)

HasFileWithPath checks if there exists a file with this path in the library

func (*Library) HasSeriesWithImdbID

func (lib *Library) HasSeriesWithImdbID(id int) (bool, error)

HasSeriesWithImdbID checks if there exists a series with this id in the library

func (*Library) HasShowWithImdbID

func (lib *Library) HasShowWithImdbID(id int) (bool, error)

HasShowWithImdbID checks if there exists a show with this id in the library

func (*Library) Save

func (lib *Library) Save(item interface{}) error

Save saves the item to the library

type Series

type Series struct {
	gorm.Model
	sync.Mutex
	CommonData

	Episodes []*Show `json:"episodes",gorm:"ForeignKey:SeriesID"`
}

Series represents a series

func (*Series) AfterCreate

func (s *Series) AfterCreate() error

AfterCreate initializes values on an empty series

type Show

type Show struct {
	gorm.Model
	sync.Mutex
	CommonData
	EpisodeData

	ReleaseDate time.Time `json:"release_date"`
	Tagline     string    `json:"tagline"`

	Files []*VideoFile `json:"files",gorm:"ForeignKey:ShowID"`
}

Show is a movie or an episode of a series

func (*Show) AfterCreate

func (s *Show) AfterCreate() error

AfterCreate initializes values on an empty show

type ShowWithFile

type ShowWithFile struct {
	Show *Show
	File *VideoFile
}

ShowWithFile is a pair of a Show and a VideoFile Used for cases where Show.ID == File.ShowID, but we don't want to search in the library for the show with this ID every time.

type Subtitle

type Subtitle struct {
	gorm.Model
	sync.Mutex

	Hash            string         `json:"hash"`
	Language        types.Language `gorm:"type:varchar(3)",json:"language"`
	HearingImpaired bool           `json:"hearing_impaired"`
	Filename        string         `json:"filename",sql:"unique"`
	Score           int            `json:"score"`

	VideoFileID uint
}

Subtitle represents a subtitle file

type VideoFile

type VideoFile struct {
	gorm.Model
	sync.Mutex

	Path             string          `json:"filename",sql:"unique"`
	OriginalBasename string          `json:"original_basename"`
	Size             uint64          `json:"filesize"`
	ResolutionX      uint            `json:"resolution"`
	ResolutionY      uint            `json:"resolution"`
	OsdbHash         types.BigUint64 `gorm:"type:varchar(16)",json:"osdb_hash"`
	VideoFormat      string          `json:"video_format"`
	AudioFormat      string          `json:"audio_format"`
	Framerate        float32         `json:"framerate"`
	VideoBitrate     float32         `json:"video_bitrate"`
	AudioBitrate     float32         `json:"audio_bitrate"`
	Duration         types.Duration  `json:"duration"`

	LastPlayed   time.Time      `json:"last_played"`
	LastPosition types.Duration `json:"last_position"`

	ShowID uint

	Subtitles []*Subtitle `json:"subtitles",gorm:"ForeignKey:VideoFileID"`

	ImportError    *string `json:"import_error"`
	OsdbError      *string `json:"osdb_error"`
	SubtitlesError *string `json:"subtitles_error"`
}

VideoFile reprsesents a file for an episode or movie

func (*VideoFile) AfterCreate

func (v *VideoFile) AfterCreate() error

AfterCreate initializes values on an empty video file

Jump to

Keyboard shortcuts

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