scene

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyUpdater = errors.New("no fields have been set")
View Source
var (
	ErrNotVideoFile = errors.New("not a video file")
)

Functions

func AddGallery added in v0.5.0

func AddGallery(ctx context.Context, qb PartialUpdater, o *models.Scene, galleryID int) error

func AddPerformer added in v0.5.0

func AddPerformer(ctx context.Context, qb PartialUpdater, o *models.Scene, performerID int) error

func AddTag added in v0.5.0

func AddTag(ctx context.Context, qb PartialUpdater, o *models.Scene, tagID int) error

func BatchProcess added in v0.11.0

func BatchProcess(ctx context.Context, reader Queryer, sceneFilter *models.SceneFilterType, findFilter *models.FindFilterType, fn func(scene *models.Scene) error) error

func DestroyMarker added in v0.12.0

func DestroyMarker(ctx context.Context, scene *models.Scene, sceneMarker *models.SceneMarker, qb MarkerDestroyer, fileDeleter *FileDeleter) error

DestroyMarker deletes the scene marker from the database and returns a function that removes the generated files, to be executed after the transaction is successfully committed.

func FilterFromPaths added in v0.11.0

func FilterFromPaths(paths []string) *models.SceneFilterType

FilterFromPaths creates a SceneFilterType that filters using the provided paths.

func GetDependentMovieIDs

func GetDependentMovieIDs(ctx context.Context, scene *models.Scene) ([]int, error)

GetDependentMovieIDs returns a slice of movie IDs that this scene references.

func GetDependentTagIDs

func GetDependentTagIDs(ctx context.Context, tags MarkerTagFinder, markerReader MarkerFinder, scene *models.Scene) ([]int, error)

GetDependentTagIDs returns a slice of unique tag IDs that this scene references.

func GetHash added in v0.17.0

func GetHash(f file.File, hashAlgorithm models.HashAlgorithm) string

GetHash returns the hash of the file, based on the hash algorithm provided. If hash algorithm is MD5, then Checksum is returned. Otherwise, OSHash is returned.

func GetSceneMarkersJSON

func GetSceneMarkersJSON(ctx context.Context, markerReader MarkerFinder, tagReader MarkerTagFinder, scene *models.Scene) ([]jsonschema.SceneMarker, error)

GetSceneMarkersJSON returns a slice of SceneMarker JSON representation objects corresponding to the provided scene's markers.

func GetSceneMoviesJSON

func GetSceneMoviesJSON(ctx context.Context, movieReader MovieFinder, scene *models.Scene) ([]jsonschema.SceneMovie, error)

GetSceneMoviesJSON returns a slice of SceneMovie JSON representation objects corresponding to the provided scene's scene movie relationships.

func GetStudioName

func GetStudioName(ctx context.Context, reader studio.Finder, scene *models.Scene) (string, error)

GetStudioName returns the name of the provided scene's studio. It returns an empty string if there is no studio assigned to the scene.

func GetTagNames

func GetTagNames(ctx context.Context, reader TagFinder, scene *models.Scene) ([]string, error)

GetTagNames returns a slice of tag names corresponding to the provided scene's tags.

func MigrateHash added in v0.11.0

func MigrateHash(p *paths.Paths, oldHash string, newHash string)

func PathsFilter added in v0.12.0

func PathsFilter(paths []string) *models.SceneFilterType

func Query added in v0.11.0

func Query(ctx context.Context, qb Queryer, sceneFilter *models.SceneFilterType, findFilter *models.FindFilterType) ([]*models.Scene, error)

Query queries for scenes using the provided filters.

func QueryOptions added in v0.11.0

func QueryOptions(sceneFilter *models.SceneFilterType, findFilter *models.FindFilterType, count bool) models.SceneQueryOptions

QueryOptions returns a SceneQueryOptions populated with the provided filters.

func QueryWithCount added in v0.11.0

func QueryWithCount(ctx context.Context, qb Queryer, sceneFilter *models.SceneFilterType, findFilter *models.FindFilterType) ([]*models.Scene, int, error)

QueryWithCount queries for scenes, returning the scene objects and the total count.

func SetScreenshot added in v0.11.0

func SetScreenshot(paths *paths.Paths, checksum string, imageData []byte) error

func ToBasicJSON

func ToBasicJSON(ctx context.Context, reader CoverGetter, scene *models.Scene) (*jsonschema.Scene, error)

ToBasicJSON converts a scene object into its JSON object equivalent. It does not convert the relationships to other objects, with the exception of cover image.

Types

type Config added in v0.18.0

type Config interface {
	GetVideoFileNamingAlgorithm() models.HashAlgorithm
}

type CoverGenerator added in v0.17.0

type CoverGenerator interface {
	GenerateCover(ctx context.Context, scene *models.Scene, f *file.VideoFile) error
}

type CoverGetter added in v0.17.0

type CoverGetter interface {
	GetCover(ctx context.Context, sceneID int) ([]byte, error)
}

type CoverUpdater added in v0.18.0

type CoverUpdater interface {
	UpdateCover(ctx context.Context, sceneID int, cover []byte) error
}

type Creator added in v0.18.0

type Creator interface {
	Create(ctx context.Context, newScene *models.Scene, fileIDs []file.ID) error
}

type CreatorUpdater added in v0.17.0

type CreatorUpdater interface {
	FindByFileID(ctx context.Context, fileID file.ID) ([]*models.Scene, error)
	FindByFingerprints(ctx context.Context, fp []file.Fingerprint) ([]*models.Scene, error)
	Creator
	UpdatePartial(ctx context.Context, id int, updatedScene models.ScenePartial) (*models.Scene, error)
	AddFileID(ctx context.Context, id int, fileID file.ID) error
	models.VideoFileLoader
}

type Destroyer added in v0.17.0

type Destroyer interface {
	Destroy(ctx context.Context, id int) error
}

type FileAssigner added in v0.18.0

type FileAssigner interface {
	AssignFiles(ctx context.Context, sceneID int, fileID []file.ID) error
}

type FileDeleter added in v0.12.0

type FileDeleter struct {
	*file.Deleter

	FileNamingAlgo models.HashAlgorithm
	Paths          *paths.Paths
}

FileDeleter is an extension of file.Deleter that handles deletion of scene files.

func (*FileDeleter) MarkGeneratedFiles added in v0.12.0

func (d *FileDeleter) MarkGeneratedFiles(scene *models.Scene) error

MarkGeneratedFiles marks for deletion the generated files for the provided scene.

func (*FileDeleter) MarkMarkerFiles added in v0.12.0

func (d *FileDeleter) MarkMarkerFiles(scene *models.Scene, seconds int) error

MarkMarkerFiles deletes generated files for a scene marker with the provided scene and timestamp.

type FinderByFile added in v0.17.0

type FinderByFile interface {
	FindByFileID(ctx context.Context, fileID file.ID) ([]*models.Scene, error)
}

type FullCreatorUpdater added in v0.17.0

type FullCreatorUpdater interface {
	CreatorUpdater
	Update(ctx context.Context, updatedScene *models.Scene) error
	Updater
}

type IDFinder added in v0.17.0

type IDFinder interface {
	Find(ctx context.Context, id int) (*models.Scene, error)
	FindMany(ctx context.Context, ids []int) ([]*models.Scene, error)
}

type Importer

type Importer struct {
	ReaderWriter        FullCreatorUpdater
	FileFinder          file.Getter
	StudioWriter        studio.NameFinderCreator
	GalleryFinder       gallery.Finder
	PerformerWriter     performer.NameFinderCreator
	MovieWriter         movie.NameFinderCreator
	TagWriter           tag.NameFinderCreator
	Input               jsonschema.Scene
	MissingRefBehaviour models.ImportMissingRefEnum
	FileNamingAlgorithm models.HashAlgorithm

	ID int
	// contains filtered or unexported fields
}

func (*Importer) Create

func (i *Importer) Create(ctx context.Context) (*int, error)

func (*Importer) FindExistingID

func (i *Importer) FindExistingID(ctx context.Context) (*int, error)

func (*Importer) Name

func (i *Importer) Name() string

func (*Importer) PostImport

func (i *Importer) PostImport(ctx context.Context, id int) error

func (*Importer) PreImport

func (i *Importer) PreImport(ctx context.Context) error

func (*Importer) Update

func (i *Importer) Update(ctx context.Context, id int) error

type MarkerCreatorUpdater added in v0.17.0

type MarkerCreatorUpdater interface {
	Create(ctx context.Context, newSceneMarker models.SceneMarker) (*models.SceneMarker, error)
	Update(ctx context.Context, updatedSceneMarker models.SceneMarker) (*models.SceneMarker, error)
	FindBySceneID(ctx context.Context, sceneID int) ([]*models.SceneMarker, error)
	UpdateTags(ctx context.Context, markerID int, tagIDs []int) error
}

type MarkerDestroyer added in v0.17.0

type MarkerDestroyer interface {
	FindBySceneID(ctx context.Context, sceneID int) ([]*models.SceneMarker, error)
	Destroy(ctx context.Context, id int) error
}

type MarkerFinder added in v0.17.0

type MarkerFinder interface {
	FindBySceneID(ctx context.Context, sceneID int) ([]*models.SceneMarker, error)
}

type MarkerImporter

type MarkerImporter struct {
	SceneID             int
	ReaderWriter        MarkerCreatorUpdater
	TagWriter           tag.NameFinderCreator
	Input               jsonschema.SceneMarker
	MissingRefBehaviour models.ImportMissingRefEnum
	// contains filtered or unexported fields
}

func (*MarkerImporter) Create

func (i *MarkerImporter) Create(ctx context.Context) (*int, error)

func (*MarkerImporter) FindExistingID

func (i *MarkerImporter) FindExistingID(ctx context.Context) (*int, error)

func (*MarkerImporter) Name

func (i *MarkerImporter) Name() string

func (*MarkerImporter) PostImport

func (i *MarkerImporter) PostImport(ctx context.Context, id int) error

func (*MarkerImporter) PreImport

func (i *MarkerImporter) PreImport(ctx context.Context) error

func (*MarkerImporter) Update

func (i *MarkerImporter) Update(ctx context.Context, id int) error

type MarkerRepository added in v0.18.0

type MarkerRepository interface {
	MarkerFinder
	MarkerDestroyer

	Update(ctx context.Context, updatedObject models.SceneMarker) (*models.SceneMarker, error)
}

type MarkerTagFinder added in v0.17.0

type MarkerTagFinder interface {
	tag.Finder
	TagFinder
	FindBySceneMarkerID(ctx context.Context, sceneMarkerID int) ([]*models.Tag, error)
}

type MovieFinder added in v0.17.0

type MovieFinder interface {
	Find(ctx context.Context, id int) (*models.Movie, error)
}

type PartialUpdater added in v0.17.0

type PartialUpdater interface {
	UpdatePartial(ctx context.Context, id int, updatedScene models.ScenePartial) (*models.Scene, error)
}

type PathsCoverSetter added in v0.17.0

type PathsCoverSetter struct {
	Paths               *paths.Paths
	FileNamingAlgorithm models.HashAlgorithm
}

func (*PathsCoverSetter) SetScreenshot added in v0.17.0

func (ss *PathsCoverSetter) SetScreenshot(scene *models.Scene, imageData []byte) error

type Queryer added in v0.11.0

type Queryer interface {
	Query(ctx context.Context, options models.SceneQueryOptions) (*models.SceneQueryResult, error)
}

type ScanGenerator added in v0.17.0

type ScanGenerator interface {
	Generate(ctx context.Context, s *models.Scene, f *file.VideoFile) error
}

type ScanHandler added in v0.17.0

type ScanHandler struct {
	CreatorUpdater CreatorUpdater

	CoverGenerator CoverGenerator
	ScanGenerator  ScanGenerator
	CaptionUpdater video.CaptionUpdater
	PluginCache    *plugin.Cache

	FileNamingAlgorithm models.HashAlgorithm
	Paths               *paths.Paths
}

func (*ScanHandler) Handle added in v0.17.0

func (h *ScanHandler) Handle(ctx context.Context, f file.File, oldFile file.File) error

type ScreenshotSetter added in v0.11.0

type ScreenshotSetter interface {
	SetScreenshot(scene *models.Scene, imageData []byte) error
}

type Service added in v0.17.0

type Service struct {
	File             file.Store
	Repository       Repository
	MarkerRepository MarkerRepository
	PluginCache      *plugin.Cache

	Paths  *paths.Paths
	Config Config
}

func (*Service) AssignFile added in v0.18.0

func (s *Service) AssignFile(ctx context.Context, sceneID int, fileID file.ID) error

func (*Service) Create added in v0.18.0

func (s *Service) Create(ctx context.Context, input *models.Scene, fileIDs []file.ID, coverImage []byte) (*models.Scene, error)

func (*Service) Destroy added in v0.17.0

func (s *Service) Destroy(ctx context.Context, scene *models.Scene, fileDeleter *FileDeleter, deleteGenerated, deleteFile bool) error

Destroy deletes a scene and its associated relationships from the database.

func (*Service) Merge added in v0.18.0

func (s *Service) Merge(ctx context.Context, sourceIDs []int, destinationID int, scenePartial models.ScenePartial) error

type TagFinder added in v0.17.0

type TagFinder interface {
	FindBySceneID(ctx context.Context, sceneID int) ([]*models.Tag, error)
}

type UpdateSet added in v0.11.0

type UpdateSet struct {
	ID int

	Partial models.ScenePartial

	// Not set if nil. Set to []byte{} to clear existing
	CoverImage []byte
}

UpdateSet is used to update a scene and its relationships.

func (*UpdateSet) IsEmpty added in v0.11.0

func (u *UpdateSet) IsEmpty() bool

IsEmpty returns true if there is nothing to update.

func (*UpdateSet) Update added in v0.11.0

func (u *UpdateSet) Update(ctx context.Context, qb Updater, screenshotSetter ScreenshotSetter) (*models.Scene, error)

Update updates a scene by updating the fields in the Partial field, then updates non-nil relationships. Returns an error if there is no work to be done.

func (UpdateSet) UpdateInput added in v0.11.0

func (u UpdateSet) UpdateInput() models.SceneUpdateInput

UpdateInput converts the UpdateSet into SceneUpdateInput for hook firing purposes.

type Updater added in v0.17.0

type Updater interface {
	PartialUpdater
	UpdateCover(ctx context.Context, sceneID int, cover []byte) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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