business

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: GPL-3.0 Imports: 16 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
	FileWatcherFilmManager
	WatcherMetadataGetter
	// contains filtered or unexported fields
}

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 FileWatcherFilmManager added in v1.1.0

type FileWatcherFilmManager interface {
	AddFilm(film *model.Film, update bool) error
}

type FilmCacher

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

type FilmFilterer added in v1.1.0

type FilmFilterer interface {
	AddFilm(films *model.Film)
}

FilmFilterer holds the different filters that can be applied

type FilmManager

type FilmManager struct {
	FilmStorer
	FilmCacher
	FilmMetadataGetter
	FilmFilterer
	// contains filtered or unexported fields
}

func NewFilmManager added in v1.1.0

func NewFilmManager(fs FilmStorer, fc FilmCacher, fdg FilmMetadataGetter, ff *Filterer) *FilmManager

func (FilmManager) AddFilm

func (fm FilmManager) AddFilm(film *model.Film, update bool) error

func (FilmManager) CacheFilms

func (fm FilmManager) CacheFilms()
func (fm FilmManager) EditFilmWithLink(filmID, inputUrl string) error

func (FilmManager) GetFilm

func (fm FilmManager) GetFilm(filmHexID string) (*model.Film, error)

GetFilm returns a Film from its hexadecimal ID

func (FilmManager) GetFilmPath

func (fm FilmManager) 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 (FilmManager) GetFilmSubtitlePath

func (fm FilmManager) 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 (FilmManager) GetFilms

func (fm FilmManager) GetFilms() []model.Film

GetFilms returns the full slice of films in the database

func (FilmManager) GetFilmsFiltered

func (fm FilmManager) 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 (FilmManager) GetFilmsWithActor

func (fm FilmManager) GetFilmsWithActor(actorID int64) (films []model.Film)

func (FilmManager) GetFilmsWithDirector

func (fm FilmManager) GetFilmsWithDirector(directorID int64) (films []model.Film)

func (FilmManager) GetFilmsWithWriter

func (fm FilmManager) 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 struct {
	Decades []model.Decade

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

func NewFilterer added in v1.1.0

func NewFilterer() *Filterer

func (*Filterer) AddFilm

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

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

func (*Filterer) AddFilms

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

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

func (*Filterer) GetCountries

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

func (*Filterer) GetCountryName

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

func (*Filterer) GetDecades

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

func (*Filterer) GetGenres

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

func (*Filterer) ParseParamsFilters

func (f *Filterer) 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 Paginater added in v1.1.0

type Paginater[T any] struct {
	// contains filtered or unexported fields
}

Paginater implements the GetPagination method

func NewPaginater added in v1.1.0

func NewPaginater[T any](itemsPerPage int64) *Paginater[T]

NewPaginater instantiates a new Paginater

func (*Paginater[T]) GetPagination added in v1.1.0

func (p *Paginater[T]) GetPagination(currentPage int64, items []T) ([]T, []model.Pagination)

GetPagination creates a slice of the input elements and Pagination slice

type PersonManager

type PersonManager struct {
	PersonStorer
}

func NewPersonManager added in v1.1.0

func NewPersonManager(ps PersonStorer) *PersonManager

func (PersonManager) GetFilmStaff

func (pm PersonManager) 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 (PersonManager) GetPeople

func (pm PersonManager) GetPeople() []model.Person

func (PersonManager) GetPerson

func (pm PersonManager) 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 UserManager

type UserManager struct {
	UserStorer
}

func NewUserManager added in v1.1.0

func NewUserManager(us UserStorer) *UserManager

NewUserManager creates a new UserManager

func (UserManager) CheckLogin

func (um UserManager) CheckLogin(username, password string) (user *model.User, err error)

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

func (UserManager) CreateOwner

func (um UserManager) CreateOwner(username, password1, password2 string) (*model.User, error)

func (UserManager) CreateUser

func (um UserManager) 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 (UserManager) DeleteUser

func (um UserManager) DeleteUser(userHexID string) error

func (UserManager) GetUser

func (um UserManager) GetUser(userHexID string) (*model.User, error)

func (UserManager) GetUserNb

func (um UserManager) GetUserNb() (int64, error)

func (UserManager) GetUsers

func (um UserManager) GetUsers() ([]model.User, error)

func (UserManager) SetUserPassword

func (um UserManager) 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 VolumeFilmManager added in v1.1.0

type VolumeFilmManager interface {
	AddFilm(film *model.Film, update bool) error
}

type VolumeManager

func NewVolumeManager added in v1.1.0

NewVolumeManager instantiates a new VolumeManager

func (VolumeManager) CreateVolume

func (vm VolumeManager) CreateVolume(name, path string, isRecursive bool, mediaType string) error

func (VolumeManager) DeleteVolume

func (vm VolumeManager) DeleteVolume(volumeHexID string) error

func (VolumeManager) GetVolume

func (vm VolumeManager) GetVolume(volumeHexID string) (*model.Volume, error)

func (VolumeManager) GetVolumes

func (vm VolumeManager) 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