indexer

package
v0.0.0-...-77c78fe Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound      = errors.New("Task with this name not found")
	ErrDuplicateSequence = errors.New("A Sequence with this name already exists")
	ErrSequenceNotFound  = errors.New("Sequence with this name not found")
	ErrImageDownload     = errors.New("There was an error while downloading the image")
)
View Source
var (
	ErrorNoSearchResults = errors.New("No search results for this query")
)
View Source
var (
	ErrorTooManyRetries = errors.New("Too many retries")
)

Functions

func HandleCheck

func HandleCheck(job *Job)

HandleCheck handles the check if the provided file is already indexed and an entry in the database exists or another worker has already put this movie / show into the queue for further processing

func HandleDelete

func HandleDelete(job *Job)

HandleDelete handles the deletion of an database entry if the file watcher encounters a file deletion

func HandleDownloadImages

func HandleDownloadImages(job *Job)

HandleDownloadImages handles the download of all provided images

func HandleIndex

func HandleIndex(job *Job)

HandleIndex handles the indexing based on the search result and fetches all details of the movie / show

func HandleMeta

func HandleMeta(job *Job)

func HandleMove

func HandleMove(job *Job)

HandleMove handles the update of an database entry if the file watcher encounters a file move

func HandleProbe

func HandleProbe(job *Job)

HandleProbe handles the process of extracting fps, width and height of the media file

func HandleResizeImages

func HandleResizeImages(job *Job)

HandleResizeImages handles the resizing of all downloaded images

func HandleSave

func HandleSave(job *Job)

HandleSave handles the saving of the indexed movie / show to the database

func HandleSearch

func HandleSearch(job *Job)

HandleSearch handles the search of the movie / show via the TMDB API search endpoint

func HandleSubtitles

func HandleSubtitles(job *Job)

HandleSubtitles handles the process of extracting subtitles to a srt file

Types

type File

type File struct {
	ID            int
	Info          os.FileInfo
	ContentType   string
	Path          string
	OldPath       string
	Name          string
	NameExtension string
	Hash          string
	NSWF          bool
}

type Indexer

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

func New

func New(app app.App) *Indexer

New returns a new Indexer instance

func (*Indexer) AddToCache

func (i *Indexer) AddToCache(hash string)

AddToCache adds a hash to the internal cache

func (*Indexer) CheckCache

func (i *Indexer) CheckCache(hash string) bool

CheckCache checks if a hash is present in the internal cache

func (*Indexer) Images

func (i *Indexer) Images(result *m.Result) error

Images will download all provided images and save them on local storage

func (*Indexer) Job

func (i *Indexer) Job(sequence string) (*Job, error)

Job returns a new job with the named step sequence

func (*Indexer) LogEnabled

func (i *Indexer) LogEnabled() bool

LogEnabled returns if log is anabled

func (*Indexer) MovieDetail

func (i *Indexer) MovieDetail(id int) (*m.MovieDetail, error)

MovieDetail performs a request against the TheMovieDB API querying for all details about the provided movie

func (*Indexer) MovieResult

func (i *Indexer) MovieResult(detail *m.MovieDetail, file File) *m.Result

func (*Indexer) MovieSearch

func (i *Indexer) MovieSearch(name string) (int, error)

MovieSearch performs a search of the provided filename against the TheMovieDB API. If no movie is found this will return 0 as ID and an error

func (*Indexer) Next

func (i *Indexer) Next(job *Job)

Next advances to the next job step

func (*Indexer) Probe

func (i *Indexer) Probe(result *m.Result) error

Probe executes a ffprobe on the source file to extract video fps, width and height

func (*Indexer) PurgeCacheEntry

func (i *Indexer) PurgeCacheEntry(hash string)

PurgeCacheEntry removes a specific hash from the internal cache

func (*Indexer) RegisterTasks

func (i *Indexer) RegisterTasks(tasks map[string]func(*Job))

RegisterTasks registers a task map

func (*Indexer) ResizeImages

func (i *Indexer) ResizeImages(result *m.Result) error

ResizeImages resizes all provided images to the given sizes and saves them in their appropriate directory

func (*Indexer) Sequence

func (i *Indexer) Sequence(name string, maxRetries int, s ...string) error

Sequence registers a new step sequence or returns an error if a sequence with the same name already exists

func (*Indexer) ShowSearch

func (i *Indexer) ShowSearch(name string) (int, error)

func (*Indexer) Start

func (i *Indexer) Start()

Start starts the Indexer

func (*Indexer) Stop

func (i *Indexer) Stop()

Stop stops the Indexer

func (*Indexer) Submit

func (i *Indexer) Submit(job *Job)

Submit submits a job into the waiting queue

func (*Indexer) Subtitles

func (i *Indexer) Subtitles(result *m.Result) error

Subtitles executes a ffmpeg cmd on the source file to extract the subtitles

func (*Indexer) Visit

func (i *Indexer) Visit(md m.Source) filepath.WalkFunc

Visit is a filepath.WalkFunc and gets executed with each iteration of walk

func (*Indexer) Walk

func (i *Indexer) Walk(md m.Source)

Walk will walk a directory tree beginning from root recursivly executing the visit function upon finding a file or directory until all branches are walked

type Job

type Job struct {
	SequenceName string
	Sequence     []Step
	Current      int
	Delay        float64
	File         File
	Result       *m.Result
	Indexer      *Indexer
	// contains filtered or unexported fields
}

func (Job) DB

func (j Job) DB() *db.DB

DB returns the database instance

func (*Job) GetMaxRetries

func (j *Job) GetMaxRetries() int

GetMaxRetries returns the current retries

func (*Job) GetRetries

func (j *Job) GetRetries() int

GetRetries returns the current retries

func (*Job) Next

func (j *Job) Next()

Next advances to the next step in the sequence

func (*Job) Retry

func (j *Job) Retry() error

Retry increases the retry counter or returns an error if there were more than 3 retries

func (*Job) SetGeneral

func (j *Job) SetGeneral(info os.FileInfo, path, contentType string)

SetGeneral sets some general values

func (*Job) Wait

func (j *Job) Wait()

Wait waits x duration until retrying

type Step

type Step struct {
	Work       string
	Retries    int
	MexRetries int
}

type Worker

type Worker struct {
	Done          sync.WaitGroup
	ReadyQueue    chan chan *Job
	AssignedQueue chan *Job
	Indexer       *Indexer
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(rq chan chan *Job, done sync.WaitGroup, indexer *Indexer) *Worker

func (*Worker) GetTask

func (w *Worker) GetTask(job *Job) (func(*Job), error)

func (*Worker) Start

func (w *Worker) Start()

func (*Worker) Stop

func (w *Worker) Stop()

Jump to

Keyboard shortcuts

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