fileinfo

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Rar4Magic is the magic signature for RAR 4.x archives
	Rar4Magic = []byte{0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00}

	// Rar5Magic is the magic signature for RAR 5.x archives
	Rar5Magic = []byte{0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x01, 0x00}

	// SevenZipMagic is the magic signature for 7-Zip archives
	SevenZipMagic = []byte{0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C}
)

RAR magic byte signatures

Functions

func Has7zMagic

func Has7zMagic(data []byte) bool

Has7zMagic checks if the data contains 7-Zip magic bytes

func HasRar4Magic

func HasRar4Magic(data []byte) bool

HasRar4Magic checks if the data contains RAR 4.x magic bytes

func HasRar5Magic

func HasRar5Magic(data []byte) bool

HasRar5Magic checks if the data contains RAR 5.x magic bytes

func HasRarMagic

func HasRarMagic(data []byte) bool

HasRarMagic checks if the data contains any RAR magic bytes (4.x or 5.x)

func HasValidExtensionLength

func HasValidExtensionLength(filename string) bool

HasValidExtensionLength checks if the extension length is between 2 and 4 characters (considered a valid/common extension length)

func Is7zFile

func Is7zFile(filename string) bool

Is7zFile checks if the filename is a 7z file based on extension pattern

func IsImportantFileType

func IsImportantFileType(filename string) bool

IsImportantFileType checks if the filename is an important file type (video, RAR, 7z, or multipart MKV)

func IsMultipartMkv

func IsMultipartMkv(filename string) bool

IsMultipartMkv checks if the filename is a multipart MKV file

func IsPar2File

func IsPar2File(filename string) bool

IsPar2File checks if a filename is a PAR2 archive

func IsProbablyObfuscated added in v0.3.0

func IsProbablyObfuscated(filename string) bool

IsProbablyObfuscated reports whether a filename is likely obfuscated. It is the exported form of isProbablyObfuscated, used by the parser to decide — before any network fetch — whether a file's NZB subject name is trustworthy enough to skip downloading its first segment.

func IsRarFile

func IsRarFile(filename string) bool

IsRarFile checks if the filename is a RAR file based on extension pattern

func IsVideoFile

func IsVideoFile(filename string) bool

IsVideoFile checks if the filename is a video file based on extension

Types

type FileInfo

type FileInfo struct {
	NzbFile       nzbparser.NzbFile  // The original NZB file
	Filename      string             // Selected filename (using priority system)
	ReleaseDate   time.Time          // Release date from NZB metadata
	FileSize      *int64             // File size (from PAR2 or yEnc headers, nil if unknown)
	IsRar         bool               // Whether this is a RAR archive (detected by magic or extension)
	Is7z          bool               // Whether this is a 7z archive (detected by extension)
	IsPar2Archive bool               // Whether this is a PAR2 archive (detected by extension)
	YencHeaders   *nntppool.YEncMeta // yEnc headers from first segment
	First16KB     []byte             // First 16KB of the file (for magic byte detection)
	OriginalIndex int                // Original position in the parsed NZB file list
}

FileInfo represents parsed information about an NZB file Similar to C# GetFileInfosStep.FileInfo

func GetFileInfos

func GetFileInfos(
	files []*NzbFileWithFirstSegment,
	par2Descriptors map[[16]byte]*par2.FileDescriptor,
	nzbFilename string,
) []*FileInfo

GetFileInfos extracts file information from NZB files with first segment data Similar to C# GetFileInfosStep.GetFileInfos

type NzbFileWithFirstSegment

type NzbFileWithFirstSegment struct {
	NzbFile       *nzbparser.NzbFile
	Headers       *nntppool.YEncMeta
	First16KB     []byte
	ReleaseDate   time.Time
	SubjectHeader string // Release name prefix from the subject line (before the filename)
	OriginalIndex int    // Original position in the parsed NZB file list
}

NzbFileWithFirstSegment represents an NZB file with its first segment data Similar to C# FetchFirstSegmentsStep.NzbFileWithFirstSegment

Jump to

Keyboard shortcuts

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