Documentation
¶
Overview ¶
Package importer handles completed downloads by linking episode files into the library directory tree, creating episode_files records, and marking episodes as having a file on disk.
Index ¶
- type AbsoluteEpisodeResolver
- type Service
- func (s *Service) AttachFile(ctx context.Context, episodeID, seriesID, filePath string, sizeBytes int64, ...) error
- func (s *Service) ImportFile(ctx context.Context, grabID, contentPath string) error
- func (s *Service) ImportFromHaulRecord(ctx context.Context, seriesID, contentPath string, quality plugin.Quality) error
- func (s *Service) Subscribe()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsoluteEpisodeResolver ¶
type AbsoluteEpisodeResolver interface {
AbsoluteToTMDBEpisode(tmdbID, abs int) (season, episode int, ok bool)
}
AbsoluteEpisodeResolver maps an anime absolute episode number to the TMDB (season, episode) tuple Pilot stores in its database. The importer uses this to attach files like "Show - 48" — fansub releases that don't carry SxxExx — to the right episode row.
Defined as an interface (rather than a concrete *animelist.Service dep) so the importer's tests can stub it without dragging in the XML loader. Production wiring passes the real service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service subscribes to TypeDownloadDone events and imports completed files into the library directory tree.
func NewService ¶
func NewService(q db.Querier, bus *events.Bus, logger *slog.Logger, mm *mediamanagement.Service, animeR AbsoluteEpisodeResolver) *Service
NewService creates a new Service. Pass nil for animelist when the caller doesn't have one wired up; the importer just won't resolve anime absolute-numbered files in that case (same as before this dependency existed).
func (*Service) AttachFile ¶
func (s *Service) AttachFile(ctx context.Context, episodeID, seriesID, filePath string, sizeBytes int64, quality plugin.Quality) error
AttachFile transfers srcPath into the library, applying rename if configured. Creates the episode_files record and marks the episode as having a file.
func (*Service) ImportFile ¶
ImportFile performs the full import pipeline for a completed download. contentPath may be a single video file or a directory (season pack).
func (*Service) ImportFromHaulRecord ¶
func (s *Service) ImportFromHaulRecord(ctx context.Context, seriesID, contentPath string, quality plugin.Quality) error
ImportFromHaulRecord runs the import pipeline against a Haul history record without requiring a pre-existing Pilot grab_history row. Used by the "import from Haul" flow on the Activity page and the per-episode "Haul has it" badge — surfaces files that landed in Haul's downloads directory but never got attached to a Pilot episode (because the original grab lost its episode_id, or the torrent was added directly in Haul, or the file pre-dates the importer fix).
seriesID identifies the target series in Pilot's DB; contentPath is the absolute path Haul reports as save_path/name. quality is taken as the caller specifies — typically zero plugin.Quality, since the caller doesn't know what the file actually is and the parser will re-derive what it can from the filename.