structure

package
v0.0.0-...-4973d3c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checktitle

func Checktitle(useseries bool, qualcfg *config.QualityConfig, m *database.ParseInfo) bool

Checktitle checks if the given wanted title and year match the parsed title and year from the media file. It compares the wanted title against any alternate titles for the media entry from the database. Returns true if the title is unwanted and should be skipped.

func Getepisodestoimport

func Getepisodestoimport(serieid *uint, dbserieid *uint, m *apiexternal.FileParser) ([]database.DbstaticTwoUint, error)

Getepisodestoimport parses the episode identifier from the filename and returns the matching episode IDs from the database for importing. It handles different identifier formats and splitting multi-episode files.

func Getmediaid

func Getmediaid(id uint, manualid uint) uint

Getmediaid returns the manual media ID if it is non-zero, otherwise returns the regular media ID. Used to allow manually overriding the auto-detected media ID.

func ParseFileIDs

func ParseFileIDs(pathv string, filedata *scanner.NewFileData) (*apiexternal.FileParser, error)

ParseFileIDs parses the file at the given path to extract metadata. It uses the provided MediaTypeConfig and list ID. It returns a FileParser containing the parsed metadata, or an error if parsing failed.

func UpdateRootpath

func UpdateRootpath(file string, objtype string, objid *uint, cfgp *config.MediaTypeConfig)

UpdateRootpath updates the rootpath column in the database for the given object type and ID. It searches through the provided config to find which path the given file is under. It then extracts the first folder from the relative path of the file to that config path. It joins that folder with the config path to form the new rootpath value. Finally it executes a SQL update statement to update the rootpath for that object ID.

Types

type Organizer

type Organizer struct {
	// Cfgp is a pointer to the MediaTypeConfig
	Cfgp *config.MediaTypeConfig
	// CfgImport is a pointer to the MediaDataImportConfig
	CfgImport *config.MediaDataImportConfig
	// SourcepathCfg is a pointer to the PathsConfig for the source path
	SourcepathCfg *config.PathsConfig
	// TargetpathCfg is a pointer to the PathsConfig for the target path
	TargetpathCfg *config.PathsConfig
	// Checkruntime is a boolean indicating whether to check runtime during organization
	Checkruntime bool
	// Deletewronglanguage is a boolean indicating whether to delete wrong language files
	Deletewronglanguage bool
	// ManualId is a unit containing a manually set ID
	ManualId uint
}

Organizer struct contains configuration and path information for organizing media files

func NewStructure

func NewStructure(cfgp *config.MediaTypeConfig, cfgimport *config.MediaDataImportConfig, sourcepathstr, targetpathstr string) *Organizer

NewStructure initializes a new Organizer instance for organizing media files based on the provided configuration. It returns nil if structure organization is disabled or the config is invalid.

func (*Organizer) Close

func (s *Organizer) Close()

Close closes the Organizer, saving its internal state.

func (*Organizer) FileCleanup

func (s *Organizer) FileCleanup(orgadata *Organizerdata) error

FileCleanup removes the video file and cleans up the folder for the given Organizerdata. It handles both series and non-series files.

func (*Organizer) GenerateNamingTemplate

func (s *Organizer) GenerateNamingTemplate(orgadata *Organizerdata, m *apiexternal.FileParser, dbid *uint, tblepi []database.DbstaticTwoUint)

GenerateNamingTemplate generates the folder name and file name for a movie or TV show file based on the configured naming template. It looks up metadata from the database and parses the naming template to replace placeholders with actual values. It handles movies and shows differently based on the UseSeries config option.

func (*Organizer) GetSeriesEpisodes

func (s *Organizer) GetSeriesEpisodes(orgadata *Organizerdata, m *apiexternal.FileParser, serieid *uint, dbserieid *uint, skipdelete bool, cfgquality *config.QualityConfig) ([]database.DbstaticTwoUint, []string, error)

GetSeriesEpisodes checks existing files for a series episode, determines if a new file should replace them based on configured quality priorities, deletes lower priority files if enabled, and returns the list of episode IDs that are allowed to be imported along with any deleted file paths.

func (*Organizer) OrganizeMovie

func (s *Organizer) OrganizeMovie(orgadata *Organizerdata, m *apiexternal.FileParser, movieid uint, cfgquality *config.QualityConfig, deletewronglanguage bool, checkruntime bool) error

OrganizeMovie organizes a downloaded movie file by moving it to the target folder, updating the database, removing old lower quality files, and sending notifications. It takes organizer data, parsed file info, movie ID, quality config, flags to delete wrong language and check runtime, and returns any error.

func (*Organizer) OrganizeSeries

func (s *Organizer) OrganizeSeries(orgadata *Organizerdata, m *apiexternal.FileParser, serieid uint, cfgquality *config.QualityConfig, deletewronglanguage bool, checkruntime bool) error

OrganizeSeries organizes a downloaded series episode file by moving it to the target folder, updating the database, removing old lower quality files, and sending notifications. It takes organizer data, parsed file info, series ID, quality config, flags to delete wrong language and check runtime, and returns any error.

func (*Organizer) OrganizeSingleFolder

func (s *Organizer) OrganizeSingleFolder(folder string)

OrganizeSingleFolder walks the given folder to find media files, parses them to get metadata, checks that metadata against the database, and moves/renames files based on the config. It applies various filters for unsupported files, errors, etc. This handles the main logic for processing a single folder.

func (*Organizer) ParseFileAdditional

func (s *Organizer) ParseFileAdditional(orgadata *Organizerdata, m *apiexternal.FileParser, deletewronglanguage bool, wantedruntime int, checkruntime bool, cfgQuality *config.QualityConfig) error

ParseFileAdditional performs additional parsing and validation on a video file. It checks the runtime, language, and quality against configured values and cleans up the file if needed. It is used after initial parsing to enforce business logic around file properties.

type Organizerdata

type Organizerdata struct {

	// Foldername is the folder name
	Foldername string
	// Filename is the file name
	Filename string
	// Rootpath is the root path
	Rootpath string
	// Videofile is the video file path
	Videofile string
	// Listid is the list ID
	Listid int
	// Folder is the folder path
	Folder string
	// contains filtered or unexported fields
}

Organizerdata struct contains data for organizing media files

Jump to

Keyboard shortcuts

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