parser

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: 16 Imported by: 0

Documentation

Overview

parser

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAllQualityPriorities

func GenerateAllQualityPriorities()

GetAllQualityPriorities generates all possible quality priority combinations by iterating through resolutions, qualities, codecs and audios. It builds up a target Prioarr struct containing the ID and name for each, and calculates the priority value based on the quality group's reorder rules. The results are added to allQualityPrioritiesT and allQualityPrioritiesWantedT slices.

func GenerateCutoffPriorities

func GenerateCutoffPriorities()

GenerateCutoffPriorities iterates through the media type and list configurations, and sets the CutoffPriority field for any list that does not already have it set. It calls NewCutoffPrio to calculate the priority value based on the cutoff quality and resolution.

func GetDBEpisodeID

func GetDBEpisodeID(m *apiexternal.FileParser, epi string, dbserieid *uint, outid *uint)

GetDBEpisodeID queries the database to get the episode ID for the given file parser, season, and episode number. It first tries to find the episode ID based on season number, then falls back to identifier if needed. Returns the episode ID or 0 if not found.

func GetDBIDs

func GetDBIDs(m *apiexternal.FileParser) error

GetDBIDs retrieves the database IDs needed to locate a movie or TV episode in the database. It takes a FileParser struct pointer as input. This contains metadata about the media file. It first checks if it is a movie or TV show based on the config. For movies: It tries to lookup the movie by IMDb ID, trying prefixes if not found If still not found, it searches by title It gets the movie ID and list ID Returns error if not found For TV shows: Lookup by TVDB ID If not found, search by title and year Get the episode ID using other metadata Get the series ID and list ID Returns error if IDs not found The goal is to map the metadata from the file to the database IDs needed to locate that movie or episode. This allows further processing on the database data. It returns errors if it can't find the expected IDs.

func GetIDPrioritySimpleParse

func GetIDPrioritySimpleParse(row *database.FilePrio, useseries bool, qualcfg *config.QualityConfig, useall bool) int

GetIDPrioritySimpleParse calculates a priority value for a ParseInfoSimple struct based on its resolution, quality, audio, and codec IDs. It looks up the priority values for each ID, applies any priority reordering rules, and sums the priorities. The qualcfg config is used to control which IDs are used and priority reordering. The useall and checkwanted params control including all IDs vs just configured ones, and checking wanted vs all available priorities.

func GetPriorityMapQual

func GetPriorityMapQual(m *database.ParseInfo, cfgp *config.MediaTypeConfig, quality *config.QualityConfig, useall, checkwanted bool)

GetPriorityMapQual calculates priority for a ParseInfo based on its resolution, quality, codec, and audio IDs. It looks up missing IDs, applies defaults if configured, and maps IDs to names. It then calls getIDPriority to calculate the priority value.

func LoadDBPatterns

func LoadDBPatterns()

LoadDBPatterns loads patterns from database if not already loaded.

func NewFileParser

func NewFileParser(cleanName string, cfgp *config.MediaTypeConfig, listid int, allowtitlesearch bool) *apiexternal.FileParser

NewFileParser creates a new FileParser instance with the given clean filename, media type config, list ID, and allow title search flag. It initializes the parser and returns it.

func ParseFile

func ParseFile(videofile string, usepath bool, usefolder bool, cfgp *config.MediaTypeConfig, listid int) *apiexternal.FileParser

ParseFile parses the given video file to extract metadata. It accepts a video file path, booleans to indicate whether to use the path and folder to extract metadata, a media type config, a list ID, and a FileParser to populate. It calls ParseFileP to parse the file and populate the FileParser, which is then returned.

func ParseFileP

func ParseFileP(videofile string, usepath bool, usefolder bool, cfgp *config.MediaTypeConfig, listid int, m *apiexternal.FileParser)

ParseFileP parses a video file to extract metadata. It accepts the video file path, booleans to determine parsing behavior, a media type config, list ID, and existing parser to populate. It returns the populated parser after attempting to extract metadata.

func ParseVideoFile

func ParseVideoFile(m *apiexternal.FileParser, file string, quality *config.QualityConfig) error

ParseVideoFile parses metadata for a video file using ffprobe or MediaInfo. It first tries ffprobe, then falls back to MediaInfo if enabled. It takes a FileParser, path to the video file, and quality settings. It populates the FileParser with metadata parsed from the file. Returns an error if both parsing methods fail.

func RegexGetMatchesStr1

func RegexGetMatchesStr1(m *apiexternal.FileParser)

RegexGetMatchesStr1 extracts the series name from the filename by using a regular expression match. It looks for the series name substring in the filename, trims extra characters, and calls findDbserieByName to look up the series ID.

func SetDBEpisodeIDfromM

func SetDBEpisodeIDfromM(m *apiexternal.FileParser)

SetDBEpisodeIDfromM sets the DbserieEpisodeID field on the FileParser struct by looking up the episode ID in the database based on the season, episode, and identifier fields. It first tries looking up by season and episode number strings, then falls back to the identifier.

Types

type Cmdout

type Cmdout struct {
	// Out contains the stdout bytes from running the command
	Out []byte
	// Outerror contains the stderr as a string from running the command
	Outerror string
	// Err contains any error that occurred while running the command
	Err error
}

Cmdout contains the stdout, stderr, and error from running a command

func ExecCmd

func ExecCmd(com string, file string, typ string) Cmdout

ExecCmd executes the given command with the provided arguments and returns the stdout, stderr, and error. typ indicates the command type, either "ffprobe" or "mediainfo". file is the path to the file to analyze.

func (*Cmdout) Close

func (c *Cmdout) Close()

type Prioarr

type Prioarr struct {
	QualityGroup string
	ResolutionID uint
	QualityID    uint
	CodecID      uint
	AudioID      uint
	Priority     int
}

func Getallprios

func Getallprios() []Prioarr

Getallprios returns all quality priorities in descending order of quality. This is a copy

func Getcompleteallprios

func Getcompleteallprios() []Prioarr

Getcompleteallprios returns all quality priorities in descending order of quality. This is useful for testing

Jump to

Keyboard shortcuts

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