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 ¶
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 ¶
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 ¶
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.