metadata

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnrichName added in v1.7.6

func EnrichName(path string, releaseName string, releaseMetadata *types.ReleaseMetadata, season int, episode int, skipNameEnrichment bool, getMediaInfoJSON func(string) ([]byte, error)) (string, error)

EnrichName constructs a standardized release name from the given metadata and media information. It extracts and combines various metadata components (title, year, season/episode, edition tags, language, resolution, source, type, audio, video codec, group tag) into a properly formatted string.

Parameters:

  • path: File path to the media file (used to extract MediaInfo)
  • releaseName: Original release name to extract metadata from
  • releaseMetadata: Metadata containing titles (DE/EN) and year information
  • season: Season number (0 if not applicable)
  • episode: Episode number (0 if not applicable)
  • skipNameEnrichment: If true, returns a simplified name with dots replaced by spaces
  • getMediaInfoJSON: Function to retrieve MediaInfo JSON for the given path

Returns the enriched release name or an error if essential metadata cannot be extracted.

func ExtractCategoryId

func ExtractCategoryId(releaseName string) int

func ExtractReleaseSuffix added in v1.9.0

func ExtractReleaseSuffix(releaseName string) (string, error)

ExtractReleaseSuffix attempts to extract the release suffix from a release name string. It ignores episode-specific titles and repack tags for season pack comparison.

func ExtractResolutionFromMediaInfo added in v1.11.0

func ExtractResolutionFromMediaInfo(mediaInfoJSON []byte) (int, string, error)

ExtractResolutionFromMediaInfo extracts resolution from MediaInfo JSON by reading the Height field. It returns the resolution ID and label based on the actual video dimensions. This is used as a fallback when the filename doesn't contain a standard resolution pattern. For DVD content with non-standard heights (cropped DVDRips), it uses framerate to detect PAL vs NTSC.

func ExtractResolutionId

func ExtractResolutionId(releaseName string) (int, string)

func ExtractResolutionIdWithMediaInfo added in v1.11.0

func ExtractResolutionIdWithMediaInfo(releaseName string, getMediaInfoJSON func(string) ([]byte, error), path string) (int, string)

ExtractResolutionIdWithMediaInfo attempts to extract resolution from the release name first, and falls back to reading from MediaInfo if the filename doesn't contain a standard resolution pattern. For resolutions with interlaced variants (1080, 576, 480), it verifies the scan type from MediaInfo to catch mislabeled releases (e.g., 1080i content labeled as 1080p in the filename).

func ExtractSeasonAndEpisode

func ExtractSeasonAndEpisode(releaseName string) (season int, episode int)

func ExtractTypeId

func ExtractTypeId(releaseName string) int

func GetDescription

func GetDescription(cfg *configs.Config, images []services.UploadedImage, version string, userIO io.UserIO) string

getDescription generates BBCode for screenshots and signatures.

func GetIMDBIDFromString

func GetIMDBIDFromString(content string) (string, error)

getIMDBIDFromString tries to extract an IMDb ID from the given content.

func GetMediaInfoJSON

func GetMediaInfoJSON(filePath string) ([]byte, error)

GetMediaInfoJSON returns the MediaInfo JSON output for the given file path.

It runs the "mediainfo" command-line tool with JSON output on the specified file and returns the output as a byte slice.

filePath: Path to the media file to analyze.

Returns the MediaInfo JSON output as []byte, or an error if the command fails or the file does not exist.

func GetTVmazeIDFromString

func GetTVmazeIDFromString(content string) (int, error)

GetTVmazeIDFromString tries to extract a TVmaze ID from the given content.

func HasGermanAudioTrack added in v1.11.0

func HasGermanAudioTrack(filePath string, getMediaInfoJSON func(string) ([]byte, error)) bool

HasGermanAudioTrack checks if the media file at the given path has a German audio track. It parses the mediainfo JSON output and checks for German language codes (ger, de, deu, german, deutsch). Returns true if a German audio track exists, false otherwise. If an error occurs (e.g., file not found, mediainfo not available), it returns false.

func IsDailyShow

func IsDailyShow(releaseName string) bool

func IsSeasonDirectory added in v1.8.0

func IsSeasonDirectory(path string) int

IsSeasonDirectory checks if the path is a season directory and extracts the season number.

func IsTVShow

func IsTVShow(releaseName string) bool

func WriteMediaInfoToTempFile

func WriteMediaInfoToTempFile(filePath string, tempPath string) (string, string, error)

Types

type CreatingLibrary added in v1.5.0

type CreatingLibrary struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	URL     string `json:"url"`
}

type Media added in v1.5.0

type Media struct {
	Ref            string  `json:"@ref"`
	GeneralTrack   *Track  `json:"-"`
	Tracks         []Track `json:"track"`
	AudioTracks    []Track `json:"-"`
	VideoTracks    []Track `json:"-"`
	SubtitleTracks []Track `json:"-"`
}

func (*Media) UnmarshalJSON added in v1.5.0

func (m *Media) UnmarshalJSON(data []byte) error

type MediaInfo

type MediaInfo struct {
	CreatingLibrary CreatingLibrary `json:"creatingLibrary"`
	Media           Media           `json:"media"`
}

type TitleYearRest added in v1.7.6

type TitleYearRest struct {
	Title string
	Year  int
	Rest  string
}

func ExtractTitleYearRest

func ExtractTitleYearRest(releaseName string) (TitleYearRest, error)

ExtractTitleYearRest attempts to parse a release name string and extract the title, year, and the remaining metadata.

The function first tries to match common patterns for titles, years, seasons, episodes, or daily show dates using a regular expression. If a match is found, it extracts:

  • Title: The part before the year/season/episode/date, with dots replaced by spaces.
  • Year: The 4-digit year if present, otherwise 0.
  • Rest: The remainder of the string after the matched pattern, with leading dots and season/episode/date info removed.

If the main pattern does not match, it falls back to extracting the title as everything before "German" (case-insensitive), and the rest as everything after "German", including "German". Year is set to 0 in this case.

If neither approach succeeds, it returns an empty TitleYearRest struct and a non-nil error.

Example return values:

Input: "Show.Name.2022.S01E01.German.DL.1080p.WEB-DL-GROUP"
Output: TitleYearRest{Title: "Show Name", Year: 2022, Rest: "German.DL.1080p.WEB-DL-GROUP"}, nil

Input: "Movie.Title.German.DTS.1080p.BluRay"
Output: TitleYearRest{Title: "Movie Title", Year: 0, Rest: "German.DTS.1080p.BluRay"}, nil

Input: "UnparseableString"
Output: TitleYearRest{}, error

type Track

type Track struct {
	Type                      string `json:"@type"`
	TypeOrder                 *int   `json:"@typeorder,string,omitempty"`
	ID                        string `json:"ID,omitempty"`
	UniqueID                  string `json:"UniqueID,omitempty"`
	Format                    string `json:"Format,omitempty"`
	Title                     string `json:"Title,omitempty"`
	Language                  string `json:"Language,omitempty"`
	Duration                  string `json:"Duration,omitempty"`
	Channels                  string `json:"Channels,omitempty"`
	BitRate                   string `json:"BitRate,omitempty"`
	HDR_Format_Compatibility  string `json:"HDR_Format_Compatibility,omitempty"`
	HDR_Format                string `json:"HDR_Format,omitempty"`
	Transfer_Characteristics  string `json:"transfer_characteristics,omitempty"`
	Format_Version            string `json:"Format_Version,omitempty"`
	Format_AdditionalFeatures string `json:"Format_AdditionalFeatures,omitempty"`
	Height                    string `json:"Height,omitempty"`
	Width                     string `json:"Width,omitempty"`
	ScanType                  string `json:"ScanType,omitempty"`
	FrameRate                 string `json:"FrameRate,omitempty"`
	CodecID                   string `json:"CodecID,omitempty"`
	CodecID_Hint              string `json:"CodecID_Hint,omitempty"`

	// Add more fields as needed, matching the JSON keys
	Extra map[string]interface{} `json:"extra,omitempty"`
}

Jump to

Keyboard shortcuts

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