archive

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package archive extracts a subtitle from a ZIP or RAR container.

One export does the work: Extract. Everything else here is unexported, because a symbol only this package's tests reach is surface nobody has to maintain.

Each container supplies a SEQUENCE of members (zip.go, rar.go). One selection policy walks any such sequence (member.go): the entry gate, the episode match, and the classification of a miss. Extract picks which container to open and decides what a refusal means to a caller.

Which member answers for which episode is epmarker's judgement, not this package's. Only the filepath.Base narrowing is local, because a directory named for a season must not answer for a member inside it.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotArchive = errors.New("not a readable zip or rar archive")

ErrNotArchive reports that data is not a container this package can open. It is the one refusal a caller branches on: the raw bytes are still the whole story and subtitlefile.Validate is what names them. Every other refusal describes an archive that DID open.

Functions

func Decompress

func Decompress(data []byte) []byte

Decompress detects compressed data by magic bytes and decompresses it (xz, gzip). Passes through plain data unchanged. Output is capped at 5 MB.

func Extract

func Extract(data []byte, want epmarker.Target) ([]byte, error)

Extract returns the subtitle for want from an archive.

Tries ZIP first, then RAR, using magic bytes to skip a probe that cannot match. If the data is not a recognized archive, returns it only when it looks like subtitle content.

A fixed target refuses rather than falling back to an unmatched member, so a season pack cannot yield the wrong episode. An epmarker.Any target takes the first readable subtitle, which is what a movie download wants.

A nil error means the returned bytes are the answer. An error matching ErrNotArchive means nothing here could read the data; any other error describes an archive that opened and had no subtitle for this target.

Types

This section is empty.

Jump to

Keyboard shortcuts

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