scrape

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailNFO

func DetailNFO(detail domain.MovieDetail) nfo.Movie

DetailNFO converts a catalogue MovieDetail into an NFO Document.

func ExportLocalMovie added in v0.1.1

func ExportLocalMovie(embyDir, publicURL, strmToken string, record *ent.Movie, images *mediaimage.Cache) (bool, error)

ExportLocalMovie repairs missing or changed outputs using saved metadata and artwork.

func MovieArtwork

func MovieArtwork(record *ent.Movie) mediaimage.Artwork

MovieArtwork extracts the artwork URLs from an indexed ent.Movie record.

func MovieNFO

func MovieNFO(record *ent.Movie) (nfo.Movie, error)

MovieNFO reads the complete document saved by scraping or NFO import.

func SaveMovieMetadata

func SaveMovieMetadata(ctx context.Context, tx *ent.Tx, id int, doc nfo.Movie) error

SaveMovieMetadata updates an ent.Movie record and associates actors and tags from an NFO document.

func SnapshotMatches added in v0.1.3

func SnapshotMatches(record *ent.Movie, source domain.LibrarySource) bool

SnapshotMatches checks the exported videos and generated poster revision.

func VideoFingerprint

func VideoFingerprint(files []pan.File) string

VideoFingerprint computes a deterministic hash of a movie's video files.

Types

type Dependencies added in v0.1.3

type Dependencies struct {
	ExportManager *export.Manager
	MediaNotifier export.MediaNotifier
	Subtitles     SubtitleExporter
}

type MetadataPayload

type MetadataPayload struct {
	Rebuild    bool                 `json:"rebuild,omitempty"`
	Source     domain.LibrarySource `json:"source"`
	ScanTaskID int                  `json:"scan_task_id"`
	MovieID    int                  `json:"movie_id"`
	Code       string               `json:"code"`
	JavDBID    string               `json:"javdb_id,omitempty"`
	ManualCode string               `json:"manual_code,omitempty"`
}

MetadataPayload describes the input for a movie scrape job.

type MetadataSource added in v0.2.0

MetadataSource resolves independent sources and downloads their image candidates.

type MovieDirectory

type MovieDirectory struct {
	ID       string
	VideoIDs map[string]bool
	Files    []pan.File
}

MovieDirectory groups a movie's indexed videos with the current directory listing.

type Notifier

type Notifier interface {
	NotifyLibraryChanged()
	WakePool()
}

Notifier reports committed library updates and queued follow-up work.

type Payload added in v0.2.0

type Payload struct {
	MetadataPayload
	MetadataReady bool                `json:"metadata_ready,omitempty"`
	Document      nfo.Movie           `json:"document"`
	Artwork       *mediaimage.Artwork `json:"artwork,omitempty"`
	PosterVersion int                 `json:"poster_version,omitempty"`
	Completed     bool                `json:"completed,omitempty"`
}

Payload holds the checkpoints of one movie scraping workflow.

type Service

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

Service manages movie metadata scraping and artwork caching.

func New

func New(db *ent.Client, d *drive.Drive, metadata MetadataSource, images *mediaimage.Cache, notifier Notifier, deps Dependencies) *Service

New installs dependencies before starting subtitle workers.

func (*Service) Artwork

func (service *Service) Artwork(key string) ([]byte, error)

Artwork reads cached artwork bytes by key.

func (*Service) Close

func (service *Service) Close()

Close releases resources and terminates background workers.

func (*Service) Directories

func (service *Service) Directories(ctx context.Context, sess drive.Session, input MetadataPayload) ([]MovieDirectory, error)

Directories returns all directories containing media files for the movie.

func (*Service) Finished

func (service *Service) Finished(ctx context.Context, tx *ent.Tx, job tasks.Job, result error) (tasks.Change, error)

Finished marks the movie scrape as failed inside the completion transaction when a scrape job fails. Failures change the library view; successes only advance the download workflow projection.

func (*Service) Scrape

func (service *Service) Scrape(ctx context.Context, job tasks.Job) error

Scrape runs one recoverable movie workflow: metadata, artwork, then export.

func (*Service) TryLockArtwork

func (service *Service) TryLockArtwork() bool

TryLockArtwork attempts to acquire the artwork lock for cache maintenance.

func (*Service) UnlockArtwork

func (service *Service) UnlockArtwork()

UnlockArtwork releases the artwork lock.

type SubtitleExporter added in v0.1.3

type SubtitleExporter interface {
	Export(ctx context.Context, movieID int, target subtitlemeta.Target) (int, error)
}

SubtitleExporter writes a movie's subtitles beside its exported .strm file.

type SubtitleQueue

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

SubtitleQueue is a bounded, concurrency-controlled background worker queue for subtitle processing.

func (*SubtitleQueue) Close

func (q *SubtitleQueue) Close()

Close gracefully stops the worker pool and waits for active tasks to finish.

func (*SubtitleQueue) Enqueue

func (q *SubtitleQueue) Enqueue(task SubtitleTask)

Enqueue adds a subtitle task to the queue if not already pending and queue has capacity.

type SubtitleTask

type SubtitleTask struct {
	MovieID int
	Target  subtitlemeta.Target
}

SubtitleTask exports the subtitles of one movie after its artwork and .strm are written.

Jump to

Keyboard shortcuts

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