identify

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package identify provides the scene identification functionality for the application. The identify functionality uses scene scrapers to identify a given scene and set its metadata based on the scraped data.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSkipSingleNamePerformer = errors.New("a performer was skipped because they only had a single name and no disambiguation")
)

Functions

This section is empty.

Types

type FieldOptions added in v0.17.0

type FieldOptions struct {
	Field    string        `json:"field"`
	Strategy FieldStrategy `json:"strategy"`
	// creates missing objects if needed - only applicable for performers, tags and studios
	CreateMissing *bool `json:"createMissing"`
}

type FieldStrategy added in v0.17.0

type FieldStrategy string
const (
	// Never sets the field value
	FieldStrategyIgnore FieldStrategy = "IGNORE"
	// For multi-value fields, merge with existing.
	// For single-value fields, ignore if already set
	FieldStrategyMerge FieldStrategy = "MERGE"
	// Always replaces the value if a value is found.
	//   For multi-value fields, any existing values are removed and replaced with the
	//   scraped values.
	FieldStrategyOverwrite FieldStrategy = "OVERWRITE"
)

func (FieldStrategy) IsValid added in v0.17.0

func (e FieldStrategy) IsValid() bool

func (FieldStrategy) MarshalGQL added in v0.17.0

func (e FieldStrategy) MarshalGQL(w io.Writer)

func (FieldStrategy) String added in v0.17.0

func (e FieldStrategy) String() string

func (*FieldStrategy) UnmarshalGQL added in v0.17.0

func (e *FieldStrategy) UnmarshalGQL(v interface{}) error

type MetadataOptions added in v0.17.0

type MetadataOptions struct {
	// any fields missing from here are defaulted to MERGE and createMissing false
	FieldOptions []*FieldOptions `json:"fieldOptions"`
	// defaults to true if not provided
	SetCoverImage *bool `json:"setCoverImage"`
	SetOrganized  *bool `json:"setOrganized"`
	// defaults to true if not provided
	IncludeMalePerformers *bool `json:"includeMalePerformers"`
	// defaults to true if not provided
	SkipMultipleMatches *bool `json:"skipMultipleMatches"`
	// ID of tag to tag skipped multiple matches with
	SkipMultipleMatchTag *string `json:"skipMultipleMatchTag"`
	// defaults to true if not provided
	SkipSingleNamePerformers *bool `json:"skipSingleNamePerformers"`
	// ID of tag to tag skipped single name performers with
	SkipSingleNamePerformerTag *string `json:"skipSingleNamePerformerTag"`
}

type MultipleMatchesFoundError added in v0.22.0

type MultipleMatchesFoundError struct {
	Source ScraperSource
}

func (*MultipleMatchesFoundError) Error added in v0.22.0

func (e *MultipleMatchesFoundError) Error() string

type Options added in v0.17.0

type Options struct {
	// An ordered list of sources to identify items with. Only the first source that finds a match is used.
	Sources []*Source `json:"sources"`
	// Options defined here override the configured defaults
	Options *MetadataOptions `json:"options"`
	// scene ids to identify
	SceneIDs []string `json:"sceneIDs"`
	// paths of scenes to identify - ignored if scene ids are set
	Paths []string `json:"paths"`
}

type PerformerCreator added in v0.17.0

type PerformerCreator interface {
	models.PerformerCreator
	UpdateImage(ctx context.Context, performerID int, image []byte) error
}

type SceneCoverGetter added in v0.23.0

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

type SceneIdentifier

type SceneIdentifier struct {
	TxnManager         txn.Manager
	SceneReaderUpdater SceneReaderUpdater
	StudioReaderWriter models.StudioReaderWriter
	PerformerCreator   PerformerCreator
	TagFinderCreator   models.TagFinderCreator

	DefaultOptions              *MetadataOptions
	Sources                     []ScraperSource
	SceneUpdatePostHookExecutor SceneUpdatePostHookExecutor
}

func (*SceneIdentifier) Identify

func (t *SceneIdentifier) Identify(ctx context.Context, scene *models.Scene) error

type SceneScraper

type SceneScraper interface {
	ScrapeScenes(ctx context.Context, sceneID int) ([]*scraper.ScrapedScene, error)
}

type SceneUpdatePostHookExecutor

type SceneUpdatePostHookExecutor interface {
	ExecuteSceneUpdatePostHooks(ctx context.Context, input models.SceneUpdateInput, inputFields []string)
}

type ScraperSource

type ScraperSource struct {
	Name       string
	Options    *MetadataOptions
	Scraper    SceneScraper
	RemoteSite string
}

type Source added in v0.17.0

type Source struct {
	Source *scraper.Source `json:"source"`
	// Options defined for a source override the defaults
	Options *MetadataOptions `json:"options"`
}

Jump to

Keyboard shortcuts

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