business

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStorer

type FileStorer interface {
	GetVolumes() ([]model.Volume, error)

	AddSubtitleToFilmPath(filmFilePath string, sub model.Subtitle) error
	RemoveSubtitleFile(mediaPath, subtitlePath string) error

	GetFilmFromPath(filmPath string) (film *model.Film, err error)

	UpdateFilmVolumeFile(film *model.Film, oldPath string, newVolumeFile model.VolumeFile) error
	DeleteFilmVolumeFile(path string) error

	IsFilmPathPresent(filmPath string) bool
	IsSubtitlePathPresent(subPath string) bool
	GetFilmsFromVolume(id primitive.ObjectID) (films []model.Film)
}

type FileWatcher

type FileWatcher struct {
	FileStorer
	FilmManager
	WatcherMetadataGetter
	// contains filtered or unexported fields
}

func NewFileWatcher

func NewFileWatcher(fs FileStorer, fm FilmManager, wmg WatcherMetadataGetter) *FileWatcher

func (*FileWatcher) AddVolume

func (fw *FileWatcher) AddVolume(v *model.Volume)

func (*FileWatcher) Run

func (fw *FileWatcher) Run()

func (*FileWatcher) Stop

func (fw *FileWatcher) Stop()

type FilmCacher

type FilmCacher interface {
	CachePoster(link, key string) (bool, error)
	CacheBackdrop(link, key string) (bool, error)
	CachePhoto(link, key string) (bool, error)
}

type FilmManager

type FilmManager interface {
	CacheFilms()

	GetFilms() []model.Film
	GetFilmsFiltered(years []int, genre, country, search string) (films []model.Film)
	GetFilmsWithActor(actorID int64) (films []model.Film)
	GetFilmsWithDirector(directorID int64) (films []model.Film)
	GetFilmsWithWriter(writerID int64) (films []model.Film)

	GetFilm(filmHexID string) (*model.Film, error)
	GetFilmPath(filmHexID, filmIndex string) (string, error)
	GetFilmSubtitlePath(filmHexID, filmIndex, subtitleIndex string) (string, error)

	EditFilmWithLink(filmID, inputUrl string) error

	AddFilm(film *model.Film, update bool) error
}

type FilmManagerWrapper

type FilmManagerWrapper struct {
	FilmStorer
	FilmCacher
	FilmMetadataGetter
	Filterer
	TMDB
	// contains filtered or unexported fields
}

func (FilmManagerWrapper) AddFilm

func (fmw FilmManagerWrapper) AddFilm(film *model.Film, update bool) error

func (FilmManagerWrapper) CacheFilms

func (fmw FilmManagerWrapper) CacheFilms()
func (fmw FilmManagerWrapper) EditFilmWithLink(filmID, inputUrl string) error

func (FilmManagerWrapper) GetFilm

func (fmw FilmManagerWrapper) GetFilm(filmHexID string) (*model.Film, error)

GetFilm returns a Film from its hexadecimal ID

func (FilmManagerWrapper) GetFilmPath

func (fmw FilmManagerWrapper) GetFilmPath(filmHexID, filmIndex string) (string, error)

GetFilmPath returns the filepath to a film given its hexadecimal ID and its index in the volume file slice

func (FilmManagerWrapper) GetFilmSubtitlePath

func (fmw FilmManagerWrapper) GetFilmSubtitlePath(filmHexID, filmIndex, subtitleIndex string) (string, error)

GetFilmSubtitlePath returns the filepath to a subtitle for a film given the film's hexadecimal ID, the film's index in the volume file slice, and the subtitle's index in the external subtitle slice

func (FilmManagerWrapper) GetFilms

func (fmw FilmManagerWrapper) GetFilms() []model.Film

GetFilms returns the full slice of films in the database

func (FilmManagerWrapper) GetFilmsFiltered

func (fmw FilmManagerWrapper) GetFilmsFiltered(years []int, genre, country, search string) []model.Film

GetFilmsFiltered returns a slice of films, filtered with years of release date, genre, country, and search terms

func (FilmManagerWrapper) GetFilmsWithActor

func (fmw FilmManagerWrapper) GetFilmsWithActor(actorID int64) (films []model.Film)

func (FilmManagerWrapper) GetFilmsWithDirector

func (fmw FilmManagerWrapper) GetFilmsWithDirector(directorID int64) (films []model.Film)

func (FilmManagerWrapper) GetFilmsWithWriter

func (fmw FilmManagerWrapper) GetFilmsWithWriter(writerID int64) (films []model.Film)

type FilmMetadataGetter

type FilmMetadataGetter interface {
	GetPosterLink(key string) string
	GetBackdropLink(key string) string
	GetPhotoLink(key string) string

	GetTMDBIDFromLink(inputUrl string) (tmdbID int, err error)
	GetPersonDetails(personID int64) *model.Person
	UpdateFilmDetails(film *model.Film)
}

type FilmStorer

type FilmStorer interface {
	GetFilms() ([]model.Film, error)
	GetFilmsFiltered(years []int, genre, country string) (films []model.Film)
	GetFilmsWithActor(actorID int64) (films []model.Film)
	GetFilmsWithDirector(directorID int64) (films []model.Film)
	GetFilmsWithWriter(writerID int64) (films []model.Film)

	GetFilmFromID(primitive.ObjectID) (*model.Film, error)
	GetPersonFromTMDBID(int64) (*model.Person, error)

	IsFilmPresent(film *model.Film) bool
	AddFilm(film *model.Film) error

	AddVolumeSourceToFilm(film *model.Film) error

	IsPersonPresent(personID int64) bool
	AddPerson(person *model.Person)
}

type Filterer

type Filterer interface {
	AddFilms(films []model.Film)
	AddFilm(films *model.Film)
	ParseParamsFilters(params string) (yearFilter string, years []int, genre, country string, page int, err error)
	GetCountryName(code string) string

	GetCountries() []string
	GetDecades() []model.Decade
	GetGenres() []string
}

Filterer holds the different filters that can be applied

type FiltererWrapper

type FiltererWrapper struct {
	Decades []model.Decade

	Genres    []string
	Countries []string
	// contains filtered or unexported fields
}

func NewFiltererWrapper

func NewFiltererWrapper() *FiltererWrapper

func (*FiltererWrapper) AddFilm

func (f *FiltererWrapper) AddFilm(film *model.Film)

AddFilm adds release year if new min or max, and missing genres to the filter

func (*FiltererWrapper) AddFilms

func (f *FiltererWrapper) AddFilms(films []model.Film)

AddFilm adds release year if new min or max, and missing genres to the filter

func (*FiltererWrapper) GetCountries

func (f *FiltererWrapper) GetCountries() []string

func (*FiltererWrapper) GetCountryName

func (f *FiltererWrapper) GetCountryName(code string) string

func (*FiltererWrapper) GetDecades

func (f *FiltererWrapper) GetDecades() []model.Decade

func (*FiltererWrapper) GetGenres

func (f *FiltererWrapper) GetGenres() []string

func (*FiltererWrapper) ParseParamsFilters

func (f *FiltererWrapper) ParseParamsFilters(params string) (yearFilter string, years []int, genre, country string, page int, err error)

ParseParamsFilters parses a params string and returns the filtered years, genre, country and page number

type PersonManager

type PersonManager interface {
	GetPeople() []model.Person

	GetPerson(personHexID string) (*model.Person, error)

	GetFilmStaff(*model.Film) ([]model.Cast, []model.Person, []model.Person, error)
}

type PersonManagerWrapper

type PersonManagerWrapper struct {
	PersonStorer
}

func NewPersonManagerWrapper

func NewPersonManagerWrapper(ps PersonStorer) *PersonManagerWrapper

func (PersonManagerWrapper) GetFilmStaff

func (pmw PersonManagerWrapper) GetFilmStaff(film *model.Film) (cast []model.Cast, directors []model.Person, writers []model.Person, err error)

GetFilmStaff returns slices of cast, directors, and writers who worked on the film

func (PersonManagerWrapper) GetPeople

func (fmw PersonManagerWrapper) GetPeople() []model.Person

func (PersonManagerWrapper) GetPerson

func (fmw PersonManagerWrapper) GetPerson(personHexID string) (*model.Person, error)

GetPerson returns a Person from its hexadecimal ID

type PersonStorer

type PersonStorer interface {
	GetPeople() ([]model.Person, error)
	GetPersonFromID(ID primitive.ObjectID) (*model.Person, error)
	GetPersonFromTMDBID(ID int64) (*model.Person, error)
}

type TMDB

type TMDB interface {
}

type UserManager

type UserManager interface {
	CreateOwner(username, password1, password2 string) (*model.User, error)
	GetUserNb() (int64, error)
	CreateUser(username, password1, password2 string, isAdmin, isOwner bool) (*model.User, error)
	DeleteUser(userHexID string) error
	CheckLogin(username, password string) (user *model.User, err error)
	SetUserPassword(username, oldPassword, password1, password2 string) error
	GetUser(userHexID string) (*model.User, error)
	GetUsers() ([]model.User, error)
}

type UserManagerWrapper

type UserManagerWrapper struct {
	UserStorer
}

func NewUserManagerWrapper

func NewUserManagerWrapper(us UserStorer) *UserManagerWrapper

NewUserManager creates a new UserManager

func (UserManagerWrapper) CheckLogin

func (umw UserManagerWrapper) CheckLogin(username, password string) (user *model.User, err error)

CheckLogin checks that the login is correct and returns the user it corresponds to

func (UserManagerWrapper) CreateOwner

func (umw UserManagerWrapper) CreateOwner(username, password1, password2 string) (*model.User, error)

func (UserManagerWrapper) CreateUser

func (umw UserManagerWrapper) CreateUser(username, password1, password2 string, isAdmin, isOwner bool) (*model.User, error)

CreateUser checks that the user and password follow specific rules and adds it to the database

func (UserManagerWrapper) DeleteUser

func (umw UserManagerWrapper) DeleteUser(userHexID string) error

func (UserManagerWrapper) GetUser

func (umw UserManagerWrapper) GetUser(userHexID string) (*model.User, error)

func (UserManagerWrapper) GetUserNb

func (umw UserManagerWrapper) GetUserNb() (int64, error)

func (UserManagerWrapper) GetUsers

func (umw UserManagerWrapper) GetUsers() ([]model.User, error)

func (UserManagerWrapper) SetUserPassword

func (umw UserManagerWrapper) SetUserPassword(username, oldPassword, password1, password2 string) error

SetUserPassword checks that the password change follows specific rules and updates it in the database

type UserStorer

type UserStorer interface {
	IsOwnerPresent() (bool, error)
	IsUsernameAvailable(username string) (bool, error)

	GetUserFromName(username string, user *model.User) error
	GetUserFromID(id primitive.ObjectID) (*model.User, error)
	GetUserNb() (int64, error)
	GetUsers() ([]model.User, error)

	CreateUser(user *model.User) error
	DeleteUser(userId primitive.ObjectID) error

	SetUserPassword(userID primitive.ObjectID, newPassword string) error
}

type VolumeManager

type VolumeManager interface {
	GetVolumes() ([]model.Volume, error)
	GetVolume(volumeHexID string) (*model.Volume, error)
	CreateVolume(name, path string, isRecursive bool, mediaType string) error
	DeleteVolume(volumeHexID string) error
}

type VolumeManagerWrapper

type VolumeManagerWrapper struct {
	VolumeStorer
	VolumeMetadataGetter
	FilmManager
	*FileWatcher
}

func (VolumeManagerWrapper) CreateVolume

func (vmw VolumeManagerWrapper) CreateVolume(name, path string, isRecursive bool, mediaType string) error

func (VolumeManagerWrapper) DeleteVolume

func (vmw VolumeManagerWrapper) DeleteVolume(volumeHexID string) error

func (VolumeManagerWrapper) GetVolume

func (vmw VolumeManagerWrapper) GetVolume(volumeHexID string) (*model.Volume, error)

func (VolumeManagerWrapper) GetVolumes

func (vmw VolumeManagerWrapper) GetVolumes() ([]model.Volume, error)

type VolumeMetadataGetter

type VolumeMetadataGetter interface {
	CreateFilm(file string, volumeID primitive.ObjectID, subFiles []string) *model.Film
	FetchFilmTMDBID(f *model.Film) error
	UpdateFilmDetails(film *model.Film)
}

type VolumeStorer

type VolumeStorer interface {
	GetVolumes() ([]model.Volume, error)
	GetVolumeFromID(id primitive.ObjectID) (volume *model.Volume, err error)
	AddVolume(volume *model.Volume) error
	DeleteVolume(volumeId primitive.ObjectID) error
}

type WatcherMetadataGetter

type WatcherMetadataGetter interface {
	CreateFilm(file string, volumeID primitive.ObjectID, subFiles []string) *model.Film
	FetchFilmTMDBID(f *model.Film) error
	UpdateFilmDetails(film *model.Film)
}

Jump to

Keyboard shortcuts

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