scene

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: AGPL-3.0 Imports: 27 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 models.SceneUpdater, o *models.Scene, galleryID int) error

func AddPerformer added in v0.5.0

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

func AddTag added in v0.5.0

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

func BatchProcess added in v0.11.0

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

func CountByStudioID added in v0.22.0

func CountByStudioID(ctx context.Context, r models.SceneQueryer, id int, depth *int) (int, error)

func CountByTagID added in v0.22.0

func CountByTagID(ctx context.Context, r models.SceneQueryer, id int, depth *int) (int, error)

func DestroyMarker added in v0.12.0

func DestroyMarker(ctx context.Context, scene *models.Scene, sceneMarker *models.SceneMarker, qb models.SceneMarkerDestroyer, 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 TagFinder, markerReader models.SceneMarkerFinder, 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 models.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 models.SceneMarkerFinder, tagReader TagFinder, 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 models.MovieGetter, 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 models.StudioGetter, 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 MarkerCountByTagID added in v0.22.0

func MarkerCountByTagID(ctx context.Context, r models.SceneMarkerQueryer, id int, depth *int) (int, error)

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 models.SceneQueryer, 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 models.SceneQueryer, sceneFilter *models.SceneFilterType, findFilter *models.FindFilterType) ([]*models.Scene, int, error)

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

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 CoverGetter added in v0.17.0

type CoverGetter interface {
	GetCover(ctx context.Context, sceneID int) ([]byte, 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 FilenameParser added in v0.22.0

type FilenameParser struct {
	Pattern     string
	ParserInput models.SceneParserInput
	Filter      *models.FindFilterType
	// contains filtered or unexported fields
}

func NewFilenameParser added in v0.22.0

func NewFilenameParser(filter *models.FindFilterType, config models.SceneParserInput) *FilenameParser

func (*FilenameParser) Parse added in v0.22.0

type FilenameParserRepository added in v0.22.0

type FilenameParserRepository struct {
	Scene     models.SceneQueryer
	Performer PerformerNamesFinder
	Studio    models.StudioQueryer
	Movie     MovieNameFinder
	Tag       models.TagQueryer
}

type HashFinderCoverUpdater added in v0.20.0

type HashFinderCoverUpdater interface {
	FindByChecksum(ctx context.Context, checksum string) ([]*models.Scene, error)
	FindByOSHash(ctx context.Context, oshash string) ([]*models.Scene, error)
	HasCover(ctx context.Context, sceneID int) (bool, error)
	UpdateCover(ctx context.Context, sceneID int, cover []byte) error
}

type Importer

type Importer struct {
	ReaderWriter        ImporterReaderWriter
	FileFinder          models.FileFinder
	StudioWriter        models.StudioFinderCreator
	GalleryFinder       models.GalleryFinder
	PerformerWriter     models.PerformerFinderCreator
	MovieWriter         models.MovieFinderCreator
	TagWriter           models.TagFinderCreator
	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 ImporterReaderWriter added in v0.23.0

type ImporterReaderWriter interface {
	models.SceneCreatorUpdater
	FindByFileID(ctx context.Context, fileID models.FileID) ([]*models.Scene, error)
}

type MarkerCreatorUpdater added in v0.17.0

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

type MarkerImporter

type MarkerImporter struct {
	SceneID             int
	ReaderWriter        MarkerCreatorUpdater
	TagWriter           models.TagFinderCreator
	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 MigrateSceneScreenshotsInput added in v0.20.0

type MigrateSceneScreenshotsInput struct {
	DeleteFiles       bool `json:"deleteFiles"`
	OverwriteExisting bool `json:"overwriteExisting"`
}

type MovieNameFinder added in v0.22.0

type MovieNameFinder interface {
	FindByName(ctx context.Context, name string, nocase bool) (*models.Movie, error)
}

type PerformerNamesFinder added in v0.22.0

type PerformerNamesFinder interface {
	FindByNames(ctx context.Context, names []string, nocase bool) ([]*models.Performer, error)
}

type ScanCreatorUpdater added in v0.23.0

type ScanCreatorUpdater interface {
	FindByFileID(ctx context.Context, fileID models.FileID) ([]*models.Scene, error)
	FindByFingerprints(ctx context.Context, fp []models.Fingerprint) ([]*models.Scene, error)
	GetFiles(ctx context.Context, relatedID int) ([]*models.VideoFile, error)

	Create(ctx context.Context, newScene *models.Scene, fileIDs []models.FileID) error
	UpdatePartial(ctx context.Context, id int, updatedScene models.ScenePartial) (*models.Scene, error)
	AddFileID(ctx context.Context, id int, fileID models.FileID) error
}

type ScanGenerator added in v0.17.0

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

type ScanHandler added in v0.17.0

type ScanHandler struct {
	CreatorUpdater ScanCreatorUpdater

	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 models.File, oldFile models.File) error

type ScreenshotMigrator added in v0.20.0

type ScreenshotMigrator struct {
	Options      MigrateSceneScreenshotsInput
	SceneUpdater HashFinderCoverUpdater
	TxnManager   txn.Manager
}

func (*ScreenshotMigrator) MigrateScreenshots added in v0.20.0

func (m *ScreenshotMigrator) MigrateScreenshots(ctx context.Context, screenshotPath string) error

type Service added in v0.17.0

type Service struct {
	File             models.FileReaderWriter
	Repository       models.SceneReaderWriter
	MarkerRepository models.SceneMarkerReaderWriter
	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 models.FileID) error

func (*Service) Create added in v0.18.0

func (s *Service) Create(ctx context.Context, input *models.Scene, fileIDs []models.FileID, 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 {
	models.TagGetter
	FindBySceneID(ctx context.Context, sceneID int) ([]*models.Tag, error)
	FindBySceneMarkerID(ctx context.Context, sceneMarkerID 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 models.SceneUpdater) (*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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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