parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtractedFileInfo

type ExtractedFileInfo struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
}

type FirstSegmentData

type FirstSegmentData struct {
	File                *nzbparser.NzbFile // Reference to the NZB file (for groups, subject, metadata)
	Headers             nntppool.YEncMeta  // yEnc headers (FileName, FileSize, PartSize)
	RawBytes            []byte             // Up to 16KB of raw data for PAR2 detection (may be less if segment is smaller)
	MissingFirstSegment bool               // True if first segment download failed (article not found, etc.)
	IsArticleNotFound   bool               // True only when 430 Not Found (permanent); false for timeouts/transient
	OriginalIndex       int                // Original position in the parsed NZB file list
}

FirstSegmentData holds cached data from the first segment of an NZB file This avoids redundant fetching when both PAR2 extraction and file parsing need the same data

type NzbType

type NzbType string

NzbType represents the type of NZB content

const (
	NzbTypeSingleFile NzbType = "single_file"
	NzbTypeMultiFile  NzbType = "multi_file"
	NzbTypeRarArchive NzbType = "rar_archive"
	NzbType7zArchive  NzbType = "7z_archive"
	NzbTypeStrm       NzbType = "strm_file"
)

type ParsedFile

type ParsedFile struct {
	Subject       string
	Filename      string
	Size          int64
	Segments      []*metapb.SegmentData
	Groups        []string
	IsRarArchive  bool
	Is7zArchive   bool
	IsPar2Archive bool
	Encryption    metapb.Encryption // Encryption type (e.g., "rclone"), nil if not encrypted
	Password      string            // Password from NZB meta, nil if not encrypted
	Salt          string            // Salt from NZB meta, nil if not encrypted
	ReleaseDate   time.Time         // Release date from the Usenet post
	OriginalIndex int               // Original position in the parsed NZB file list
	NzbdavID      string            // Original ID from nzbdav (for backward compatibility)
	AesKey        []byte            // AES encryption key (for nzbdav compatibility)
	AesIv         []byte            // AES initialization vector (for nzbdav compatibility)
}

ParsedFile represents a file extracted from the NZB

type ParsedNzb

type ParsedNzb struct {
	Path          string
	Filename      string
	TotalSize     int64
	Type          NzbType
	Files         []ParsedFile
	SegmentsCount int

	ExtractedFiles []ExtractedFileInfo
	// contains filtered or unexported fields
}

ParsedNzb contains the parsed NZB data and extracted metadata

func (*ParsedNzb) GetPassword

func (p *ParsedNzb) GetPassword() string

GetPassword returns the password for this NZB

func (*ParsedNzb) SetPassword

func (p *ParsedNzb) SetPassword(password string)

SetPassword sets the password for this NZB

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser handles NZB file parsing

func NewParser

func NewParser(poolManager pool.Manager) *Parser

NewParser creates a new NZB parser

func (*Parser) GetMetadata

func (p *Parser) GetMetadata(nzbXML *nzbparser.Nzb) map[string]string

GetMetadata extracts metadata from the NZB head section

func (*Parser) ParseFile

func (p *Parser) ParseFile(ctx context.Context, r io.Reader, nzbPath string, progressTracker progress.ProgressTracker) (*ParsedNzb, error)

ParseFile parses an NZB file from a reader. progressTracker, if non-nil, receives incremental updates as first segments are fetched (the longest phase). It is safe to pass nil — updates are skipped.

func (*Parser) ValidateNzb

func (p *Parser) ValidateNzb(parsed *ParsedNzb) error

ValidateNzb performs basic validation on the parsed NZB

type StrmParser

type StrmParser struct {
	// contains filtered or unexported fields
}

StrmParser handles STRM file parsing containing NXG links

func NewStrmParser

func NewStrmParser() *StrmParser

NewStrmParser creates a new STRM parser

func (*StrmParser) ParseStrmFile

func (p *StrmParser) ParseStrmFile(r io.Reader, strmPath string) (*ParsedNzb, error)

ParseStrmFile parses a STRM file containing an NXG link

func (*StrmParser) ValidateStrmFile

func (p *StrmParser) ValidateStrmFile(parsed *ParsedNzb) error

ValidateStrmFile performs basic validation on the parsed STRM file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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