scene

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const LangUnknown = "00"

to be used for captions without a language code in the filename ISO 639-1 uses 2 or 3 a-z chars for codes so 00 is a safe non valid choise https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

Variables

View Source
var CaptionExts = []string{"vtt", "srt"} // in a case where vtt and srt files are both provided prioritize vtt file due to native support
View Source
var ErrEmptyUpdater = errors.New("no fields have been set")

Functions

func AddGallery added in v0.5.0

func AddGallery(qb models.SceneReaderWriter, id int, galleryID int) (bool, error)

func AddPerformer added in v0.5.0

func AddPerformer(qb models.SceneReaderWriter, id int, performerID int) (bool, error)

func AddTag added in v0.5.0

func AddTag(qb models.SceneReaderWriter, id int, tagID int) (bool, error)

func BatchProcess added in v0.11.0

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

func CleanCaptions added in v0.15.0

func CleanCaptions(scenePath string, captions []*models.SceneCaption) (cleanedCaptions []*models.SceneCaption, changed bool)

CleanCaptions removes non existent/accessible language codes from captions

func Destroy added in v0.12.0

func Destroy(scene *models.Scene, repo models.Repository, fileDeleter *FileDeleter, deleteGenerated, deleteFile bool) error

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

func DestroyMarker added in v0.12.0

func DestroyMarker(scene *models.Scene, sceneMarker *models.SceneMarker, qb models.SceneMarkerWriter, 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 FileScanner added in v0.11.0

func FileScanner(hasher file.Hasher, fileNamingAlgorithm models.HashAlgorithm, calculateMD5 bool) file.Scanner

func FilterFromPaths added in v0.11.0

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

FilterFromPaths creates a SceneFilterType that filters using the provided paths.

func GenerateCaptionCandidates added in v0.15.0

func GenerateCaptionCandidates(captionPath string, exts []string) []string

GenerateCaptionCandidates generates a list of filenames with exts as extensions that can associated with the caption

func GetCaptionPath added in v0.15.0

func GetCaptionPath(path, lang, suffix string) string

GetCaptionPath generates the path of a caption from a given file path, wanted language and caption sufffix

func GetCaptionsLangFromPath added in v0.15.0

func GetCaptionsLangFromPath(captionPath string) string

GetCaptionsLangFromPath returns the language code from a given captions path If no valid language is present LangUknown is returned

func GetDependentMovieIDs

func GetDependentMovieIDs(sceneReader models.SceneReader, scene *models.Scene) ([]int, error)

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

func GetDependentTagIDs

func GetDependentTagIDs(tags models.TagReader, markerReader models.SceneMarkerReader, scene *models.Scene) ([]int, error)

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

func GetFunscriptPath added in v0.14.0

func GetFunscriptPath(path string) string

GetFunscriptPath returns the path of a file with the extension changed to .funscript

func GetSceneMarkersJSON

func GetSceneMarkersJSON(markerReader models.SceneMarkerReader, tagReader models.TagReader, 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(movieReader models.MovieReader, sceneReader models.SceneReader, 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(reader models.StudioReader, 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(reader models.TagReader, scene *models.Scene) ([]string, error)

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

func IsLangInCaptions added in v0.15.0

func IsLangInCaptions(lang string, ext string, captions []*models.SceneCaption) bool

IsLangInCaptions returns true if lang is present in the captions

func IsValidLanguage added in v0.15.0

func IsValidLanguage(lang string) bool

IsValidLanguage checks whether the given string is a valid ISO 639 language code

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(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(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 ReadSubs added in v0.15.0

func ReadSubs(path string) (*astisub.Subtitles, error)

ReadSubs reads a captions file

func SetScreenshot added in v0.11.0

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

func ToBasicJSON

func ToBasicJSON(reader models.SceneReader, 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.

func UpdateChecksum added in v0.5.0

func UpdateChecksum(qb models.SceneWriter, id int, checksum string) (*models.Scene, error)

func UpdateFileModTime added in v0.5.0

func UpdateFileModTime(qb models.SceneWriter, id int, modTime models.NullSQLiteTimestamp) (*models.Scene, error)

func UpdateFormat added in v0.5.0

func UpdateFormat(qb models.SceneWriter, id int, format string) (*models.Scene, error)

func UpdateOSHash added in v0.5.0

func UpdateOSHash(qb models.SceneWriter, id int, oshash string) (*models.Scene, error)

Types

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 Importer

type Importer struct {
	ReaderWriter        models.SceneReaderWriter
	StudioWriter        models.StudioReaderWriter
	GalleryWriter       models.GalleryReaderWriter
	PerformerWriter     models.PerformerReaderWriter
	MovieWriter         models.MovieReaderWriter
	TagWriter           models.TagReaderWriter
	Input               jsonschema.Scene
	Path                string
	MissingRefBehaviour models.ImportMissingRefEnum
	FileNamingAlgorithm models.HashAlgorithm

	ID int
	// contains filtered or unexported fields
}

func (*Importer) Create

func (i *Importer) Create() (*int, error)

func (*Importer) FindExistingID

func (i *Importer) FindExistingID() (*int, error)

func (*Importer) Name

func (i *Importer) Name() string

func (*Importer) PostImport

func (i *Importer) PostImport(id int) error

func (*Importer) PreImport

func (i *Importer) PreImport() error

func (*Importer) Update

func (i *Importer) Update(id int) error

type MarkerImporter

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

func (*MarkerImporter) Create

func (i *MarkerImporter) Create() (*int, error)

func (*MarkerImporter) FindExistingID

func (i *MarkerImporter) FindExistingID() (*int, error)

func (*MarkerImporter) Name

func (i *MarkerImporter) Name() string

func (*MarkerImporter) PostImport

func (i *MarkerImporter) PostImport(id int) error

func (*MarkerImporter) PreImport

func (i *MarkerImporter) PreImport() error

func (*MarkerImporter) Update

func (i *MarkerImporter) Update(id int) error

type PathsScreenshotSetter added in v0.11.0

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

func (*PathsScreenshotSetter) SetScreenshot added in v0.11.0

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

type Queryer added in v0.11.0

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

type Scanner added in v0.11.0

type Scanner struct {
	file.Scanner

	StripFileExtension  bool
	UseFileMetadata     bool
	FileNamingAlgorithm models.HashAlgorithm

	CaseSensitiveFs  bool
	TxnManager       models.TransactionManager
	Paths            *paths.Paths
	Screenshotter    screenshotter
	VideoFileCreator videoFileCreator
	PluginCache      *plugin.Cache
	MutexManager     *utils.MutexManager
}

func (*Scanner) ScanExisting added in v0.11.0

func (scanner *Scanner) ScanExisting(ctx context.Context, existing file.FileBased, file file.SourceFile) (err error)

func (*Scanner) ScanNew added in v0.11.0

func (scanner *Scanner) ScanNew(ctx context.Context, file file.SourceFile) (retScene *models.Scene, err error)

type ScreenshotSetter added in v0.11.0

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

type UpdateSet added in v0.11.0

type UpdateSet struct {
	ID int

	Partial models.ScenePartial

	// Not set if nil. Set to []int{} to clear existing
	PerformerIDs []int
	// Not set if nil. Set to []int{} to clear existing
	TagIDs []int
	// Not set if nil. Set to []int{} to clear existing
	StashIDs []models.StashID
	// 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(qb models.SceneWriter, 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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