infrastructure

package
v1.1.0 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: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(cachePath string) *Cache

NewCache initializes the cache folder

func (Cache) CacheBackdrop

func (c Cache) CacheBackdrop(sourceUrl, key string) (hasToWait bool, err error)

CachePoster caches a backdrop from a source URL and the unique key for this backdrop

func (Cache) CacheFile

func (c Cache) CacheFile(sourceUrl string, filePath string) (hasToWait bool, err error)

CacheFile caches a file from a sourceUrl to the filePath in the cache folder Returns true if the URL returns a Status TooManyRequests (429) and will retry at a later moment Returns false if the file was immediately cached

func (Cache) CachePhoto

func (c Cache) CachePhoto(sourceUrl, key string) (hasToWait bool, err error)

CachePoster caches a photo from a source URL and the unique key for this photo

func (Cache) CachePoster

func (c Cache) CachePoster(sourceUrl, key string) (hasToWait bool, err error)

CachePoster caches a poster from a source URL and the unique key for this poster

func (Cache) GetCachedPath

func (c Cache) GetCachedPath(filePath string) string

GetCachedPath returns the full path from a filepath in the cache

type Metadata

type Metadata 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
	CreateFilm(file string, volumeID primitive.ObjectID, subFiles []string) *model.Film
	FetchFilmTMDBID(f *model.Film) error
	UpdateFilmDetails(film *model.Film)
}

type MetadataWrapper

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

func NewMetadataWrapper

func NewMetadataWrapper(tmdbAPIKey string) (*MetadataWrapper, error)

NewMetadataWrapper initializes a MetadataWrapper

func (MetadataWrapper) CreateFilm

func (mw MetadataWrapper) CreateFilm(file string, volumeID primitive.ObjectID, subFiles []string) *model.Film

func (MetadataWrapper) FetchFilmTMDBID

func (mw MetadataWrapper) FetchFilmTMDBID(f *model.Film) error

FetchMediaID fetches media ID from TMDB and stores it

func (mw MetadataWrapper) GetBackdropLink(key string) string

GetBackdropLink caches a backdrop from TMDB using its id

func (MetadataWrapper) GetPersonDetails

func (mw MetadataWrapper) GetPersonDetails(personID int64) *model.Person

GetPersonDetails fetches details about a person from TMDB

func (mw MetadataWrapper) GetPhotoLink(key string) string

GetPhotoLink caches a person's photo from TMDB using its id

func (mw MetadataWrapper) GetPosterLink(key string) string

GetPosterLink caches a poster from TMDB using its id

func (mw MetadataWrapper) GetTMDBIDFromLink(inputUrl string) (tmdbID int, err error)

GetTMDBIDFromLink returns the TMDB ID from a TMDB, IMDb, or Letterboxd URL

func (MetadataWrapper) UpdateFilmDetails

func (mw MetadataWrapper) UpdateFilmDetails(film *model.Film)

type MongoDB

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

func NewMongoDB

func NewMongoDB(dbUser, dbPassword, dbURL, dbPort, dbName string) *MongoDB

NewMongoDB initializes a mongo db client

func (*MongoDB) AddActors

func (m *MongoDB) AddActors(actors []model.Person)

AddActors upserts the actors of a film to the DB

func (*MongoDB) AddFilm

func (m *MongoDB) AddFilm(film *model.Film) error

AddFilm adds a given film to the DB If the film is already in the database, updates it

func (*MongoDB) AddPerson

func (m *MongoDB) AddPerson(person *model.Person)

AddPerson adds a person to the DB TODO: upsert

func (*MongoDB) AddSubtitleToFilmPath

func (m *MongoDB) AddSubtitleToFilmPath(filmFilePath string, sub model.Subtitle) error

AddSubtitleToFilmPath adds the subtitle to a film given the film path

func (*MongoDB) AddVolume

func (m *MongoDB) AddVolume(volume *model.Volume) error

AddVolume adds a volume to the DB and start scanning the volume

func (*MongoDB) AddVolumeSourceToFilm

func (m *MongoDB) AddVolumeSourceToFilm(film *model.Film) error

AddVolumeSourceToFilm adds the volume as a source to the given media

func (*MongoDB) Close

func (m *MongoDB) Close() error

Close closes the MongoDB connection

func (*MongoDB) CreateUser

func (m *MongoDB) CreateUser(user *model.User) error

CreateUser adds a user to the database after checking parameter

func (*MongoDB) DeleteFilm

func (m *MongoDB) DeleteFilm(ID primitive.ObjectID) error

DeleteFilm deletes a film

func (*MongoDB) DeleteFilmVolumeFile

func (m *MongoDB) DeleteFilmVolumeFile(path string) error

DeleteFilmVolumeFile removes a film from the database If the film has only 1 volume file, then the film is entirely deleted

func (*MongoDB) DeleteUser

func (m *MongoDB) DeleteUser(userId primitive.ObjectID) error

DeleteUser deletes the user from the DB

func (*MongoDB) DeleteVolume

func (m *MongoDB) DeleteVolume(volumeId primitive.ObjectID) error

DeleteVolume deletes the volume from the DB and all the film which originated only from this volume

func (*MongoDB) GetFilmCount

func (m *MongoDB) GetFilmCount() int64

func (*MongoDB) GetFilmFromExternalSubtitle

func (m *MongoDB) GetFilmFromExternalSubtitle(subtitlePath string) (model.Film, error)

GetFilmFromExternalSubtitle returns a film from its external subtitle path

func (*MongoDB) GetFilmFromID

func (m *MongoDB) GetFilmFromID(id primitive.ObjectID) (*model.Film, error)

GetFilmFromID returns a film from its TMDB ID

func (*MongoDB) GetFilmFromPath

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

GetFilmFromPath retrieves a film from a path

func (*MongoDB) GetFilms

func (m *MongoDB) GetFilms() (films []model.Film, err error)

GetFilms returns a slice of Film

func (*MongoDB) GetFilmsFiltered

func (m *MongoDB) GetFilmsFiltered(years []int, genre, country string) (films []model.Film)

func (*MongoDB) GetFilmsFromVolume

func (m *MongoDB) GetFilmsFromVolume(id primitive.ObjectID) (films []model.Film)

GetFilmsFromVolume retrieves all films from a specific volume ID

func (*MongoDB) GetFilmsRange

func (m *MongoDB) GetFilmsRange(start, number int) (films []model.Film)

GetFilmsRange returns a slice of Film from start to number

func (*MongoDB) GetFilmsWithActor

func (m *MongoDB) GetFilmsWithActor(actorID int64) (films []model.Film)

GetFilmsWithActor returns a list of films starring desired actor ID

func (*MongoDB) GetFilmsWithDirector

func (m *MongoDB) GetFilmsWithDirector(directorID int64) (films []model.Film)

GetFilmsWithDirector returns a list of films directed by desired director ID

func (*MongoDB) GetFilmsWithWriter

func (m *MongoDB) GetFilmsWithWriter(writerID int64) (films []model.Film)

GetFilmsWithWriter returns a list of films written by desired writer ID

func (*MongoDB) GetPeople

func (m *MongoDB) GetPeople() (people []model.Person, err error)

func (*MongoDB) GetPersonFromID

func (m *MongoDB) GetPersonFromID(ID primitive.ObjectID) (*model.Person, error)

GetPersonFromID returns the Person struct

func (*MongoDB) GetPersonFromTMDBID

func (m *MongoDB) GetPersonFromTMDBID(TMDBID int64) (*model.Person, error)

GetPersonFromTMDBID returns the Person struct

func (*MongoDB) GetTorrents added in v1.1.0

func (m *MongoDB) GetTorrents(ctx context.Context, imdbid string, offset, limit int64) (torrents []model.RarbgTorrent, err error)

func (*MongoDB) GetUserFromID

func (m *MongoDB) GetUserFromID(id primitive.ObjectID) (*model.User, error)

GetUserFromID gets user from its ID

func (*MongoDB) GetUserFromName

func (m *MongoDB) GetUserFromName(username string, user *model.User) error

GetUserFromName gets user from it name

func (*MongoDB) GetUserNb

func (m *MongoDB) GetUserNb() (int64, error)

GetUserNb returns the number of users from the DB

func (*MongoDB) GetUsers

func (m *MongoDB) GetUsers() (users []model.User, err error)

GetUsers returns the list of users in the DB

func (*MongoDB) GetVolumeFromID

func (m *MongoDB) GetVolumeFromID(id primitive.ObjectID) (*model.Volume, error)

GetVolumeFromID fetches volume from DB using specified ID and returns it via pointer

func (*MongoDB) GetVolumes

func (m *MongoDB) GetVolumes() (volumes []model.Volume, err error)

GetVolumes returns the list of volumes in the DB

func (*MongoDB) InitRarbg added in v1.1.0

func (m *MongoDB) InitRarbg(dbName string)

func (*MongoDB) IsFilmPathPresent

func (m *MongoDB) IsFilmPathPresent(filmPath string) bool

IsFilmPathPresent checks if a film path is present in the database

func (*MongoDB) IsFilmPresent

func (m *MongoDB) IsFilmPresent(film *model.Film) bool

IsFilmPresent checks if a given film is already present in DB

func (*MongoDB) IsOwnerPresent

func (m *MongoDB) IsOwnerPresent() (bool, error)

IsOwnerPresent checks if there is an owner in the server

func (*MongoDB) IsPersonPresent

func (m *MongoDB) IsPersonPresent(personID int64) bool

IsPersonPresent checks if a person is already registered in the DB

func (*MongoDB) IsSubtitlePathPresent

func (m *MongoDB) IsSubtitlePathPresent(subPath string) bool

IsSubtitlePathPresent checks if a subtitle path is present in the database

func (*MongoDB) IsUsernameAvailable

func (m *MongoDB) IsUsernameAvailable(username string) (bool, error)

IsUsernameAvailable returns true if the username (case insensitive) is not in use yet

func (*MongoDB) RemoveSubtitleFile

func (m *MongoDB) RemoveSubtitleFile(mediaPath, subtitlePath string) error

RemoveSubtitleFile removes a film subtitle from the database

func (*MongoDB) SearchTorrents added in v1.1.0

func (m *MongoDB) SearchTorrents(ctx context.Context, search, category string, page uint) (torrents []model.RarbgTorrent, err error)

func (*MongoDB) SetUserPassword

func (m *MongoDB) SetUserPassword(userID primitive.ObjectID, newPassword string) error

SetUserPassword set a new password for a specific user

func (*MongoDB) UpdateFilmVolumeFile

func (m *MongoDB) UpdateFilmVolumeFile(film *model.Film, oldPath string, newVolumeFile model.VolumeFile) error

UpdateFilmVolumeFile updates the path to a film. film: Film struct that has its path changed oldPath: file path of the volumeFile that will be changed newVolumeFile: VolumeFile struct that replaces the previous one

Jump to

Keyboard shortcuts

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