srrdb

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package srrdb provides a Go client for the srrdb.com API and an SRR binary parser.

srrdb.com is a database for scene release reconstruction (SRR) files. This package supports searching releases, fetching file details with CRC32 checksums, retrieving NFO metadata, looking up IMDB information, downloading SRR/stored files, and parsing the SRR binary format to extract embedded files.

Create a client with New and call methods like Search, Details, NFO, IMDb, DownloadSRR, and DownloadFile. Use ParseSRR or ParseSRRReader to extract stored files from SRR binary data.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReleaseNotFound is returned when a release does not exist on srrdb.
	ErrReleaseNotFound = errors.New("srrdb: release not found")

	// ErrRateLimited is returned when srrdb returns an HTML rate-limit page.
	ErrRateLimited = errors.New("srrdb: rate limited")

	// ErrInvalidSRR is returned when SRR data cannot be parsed.
	ErrInvalidSRR = errors.New("srrdb: invalid SRR data")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Endpoint   string
}

APIError wraps an unexpected HTTP status code from the API.

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

Client communicates with the srrdb.com API.

func New

func New(opts ...Option) *Client

New creates a Client with the given options.

func (*Client) Details

func (c *Client) Details(ctx context.Context, releaseName string) (*DetailsResponse, error)

Details fetches file listings for a release. Returns ErrReleaseNotFound if the release does not exist.

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, releaseName, fileName string) ([]byte, error)

DownloadFile downloads a stored file (NFO, SFV, etc.) from a release. Returns the raw file bytes.

func (*Client) DownloadSRR

func (c *Client) DownloadSRR(ctx context.Context, releaseName string) ([]byte, error)

DownloadSRR downloads the SRR binary for a release. Returns the raw SRR file bytes.

func (*Client) IMDb

func (c *Client) IMDb(ctx context.Context, releaseName string) (*IMDbResponse, error)

IMDb fetches IMDB information linked to a release.

func (*Client) NFO

func (c *Client) NFO(ctx context.Context, releaseName string) (*NFOResponse, error)

NFO fetches NFO metadata (filenames and download links) for a release.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string) (*SearchResponse, error)

Search queries the srrdb search API. The query string follows srrdb search syntax (e.g. "category:tv title"). Multiple search terms are separated by spaces and sent as path segments.

type DetailsResponse

type DetailsResponse struct {
	Name          string     `json:"name"`
	Files         []FileInfo `json:"files"`
	ArchivedFiles []FileInfo `json:"archived-files"`
	Adds          []FileInfo `json:"adds"`
}

DetailsResponse holds file listings for a release.

type FileInfo

type FileInfo struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	CRC  string `json:"crc"`
}

FileInfo describes a file within a release (NFO, SFV, MKV, etc.).

type IMDbEntry

type IMDbEntry struct {
	IMDbID string `json:"imdb"`
	Title  string `json:"title"`
	Rating string `json:"rating"`
	Votes  string `json:"votes"`
}

IMDbEntry holds IMDB data linked to a release.

type IMDbResponse

type IMDbResponse struct {
	Releases []IMDbEntry `json:"releases"`
	Query    string      `json:"query"`
}

IMDbResponse is the top-level response from the IMDB endpoint.

type NFOResponse

type NFOResponse struct {
	Release  string   `json:"release"`
	NFO      []string `json:"nfo"`
	NFOLinks []string `json:"nfolink"`
}

NFOResponse holds NFO metadata for a release.

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseAPIURL

func WithBaseAPIURL(u string) Option

WithBaseAPIURL overrides the API base URL (for testing).

func WithBaseWebURL

func WithBaseWebURL(u string) Option

WithBaseWebURL overrides the web base URL (for testing).

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets a custom *http.Client.

func WithUserAgent

func WithUserAgent(ua string) Option

WithUserAgent sets a custom User-Agent header.

type SRRInfo

type SRRInfo struct {
	AppName     string
	StoredFiles []StoredFile
}

SRRInfo holds parsed metadata from an SRR file.

func ParseSRR

func ParseSRR(data []byte) (*SRRInfo, error)

ParseSRR parses an SRR file from raw bytes and extracts stored files.

func ParseSRRReader

func ParseSRRReader(r io.Reader) (*SRRInfo, error)

ParseSRRReader parses an SRR file from an io.Reader.

type SearchResponse

type SearchResponse struct {
	Results      []SearchResult `json:"results"`
	ResultsCount int            `json:"resultsCount"`
	Warnings     []string       `json:"warnings"`
	Query        []string       `json:"query"`
}

SearchResponse is the top-level response from the search endpoint.

type SearchResult

type SearchResult struct {
	Release   string `json:"release"`
	Date      string `json:"date"`
	HasNFO    string `json:"hasNFO"`
	HasSRS    string `json:"hasSRS"`
	IsForeign string `json:"isForeign"`
	IMDbID    string `json:"imdbId,omitempty"`
	Size      int64  `json:"size"`
}

SearchResult represents a single release from a search query.

type StoredFile

type StoredFile struct {
	Name string
	Data []byte
}

StoredFile represents a file embedded inside an SRR archive.