cardigann-go

module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: LGPL-3.0

README

cardigann-go

cardigann-go is a reusable Go implementation of the Cardigann indexer-definition engine.

It provides:

  • YAML definition parsing (definition)
  • definition fetching/sync from tarballs (defs)
  • the Cardigann search engine (engine)
  • template rendering and field filters (template, template/filters)
  • selector backends for HTML, JSON, and XML (selector)
  • per-indexer HTTP client helpers (httpclient)
  • login flows (login)
  • a library-local normalized release model (release)
  • shared HTTP utilities (internal/httputil)

Installation

go get github.com/Kcchouette/cardigann-go

Requires Go 1.21+.

Usage

package main

import (
    "fmt"
    "log"

    "github.com/Kcchouette/cardigann-go/definition"
    "github.com/Kcchouette/cardigann-go/engine"
)

func main() {
    // Parse a Cardigann YAML definition
    def, err := definition.Parse(yamlBytes)
    if err != nil {
        log.Fatal(err)
    }

    // Create a search provider
    provider := engine.NewProvider(def, "https://example.tracker.com", nil)

    // Execute a search
    releases, err := provider.Search(ctx, engine.Query{Keywords: "1080p"})
    if err != nil {
        log.Fatal(err)
    }

    for _, r := range releases {
        fmt.Printf("%s (%d bytes)\n", r.Title, r.Size)
    }
}

Breaking changes (v0.2.0)

  • CookiePersister interface: methods renamed from LoadCookies/SaveCookies to Load/Store
  • Provider struct fields (Def, BaseURL, Config, HTTPClient, Client) are now unexported. Use Provider.Def() accessor for definition access.

Supported features

Feature Status
HTML scraping (CSS selectors) Done
JSON API (gjson paths) Done
XML/RSS/Newznab (etree) Done
Login: form, cookie, get Done
21 field filters Done
Row-level filters (andmatch) Done
Template rendering Done
HTTP client (rate limit, retries, proxy) Done

Query Parameters

The following keys are available via {{ index .Query "<key>" }} in search paths and field templates. Keywords is also available as {{ .Keywords }} at the top level of the template context.

Key Type Description
Keywords string Search keywords (also: {{ .Keywords }})
q string Alias for Keywords
IMDBID string Full IMDb ID, e.g. tt1234567
IMDBIDShort string Numeric-only IMDb ID, e.g. 1234567
TMDBID string The Movie Database ID
TVDBID string TheTVDB series ID
DoubanID string Douban movie ID (Asian indexers)
Season string Season number
Ep string Episode number
Year string Release year
Genre string Genre filter string
categories string Comma-separated native category IDs (when categories are requested)

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/my-feature)
  3. Commit your changes (git commit -am 'Add my feature')
  4. Push to the branch (git push origin feat/my-feature)
  5. Open a Pull Request

License

This library is licensed under LGPL-3.0. You may use/link it from other applications, including closed-source ones, but if you distribute a modified version of this library itself, those modifications must remain available under LGPL-3.0.

  • Not affiliated with Prowlarr, Servarr, or the wider *arr ecosystem.
  • This repository does not vendor or redistribute Cardigann indexer definitions or schema.json.
  • Users are responsible for the definitions and indexers they choose to fetch or use.

Directories

Path Synopsis
Package definition contains the Go structs corresponding to the Cardigann YAML format (schema v11) used by Prowlarr/Indexers.
Package definition contains the Go structs corresponding to the Cardigann YAML format (schema v11) used by Prowlarr/Indexers.
Package defs synchronizes Cardigann definitions from the GitHub repository Prowlarr/Indexers (never vendored or redistributed, see legal disclaimer — only cached locally for the end user).
Package defs synchronizes Cardigann definitions from the GitHub repository Prowlarr/Indexers (never vendored or redistributed, see legal disclaimer — only cached locally for the end user).
Package engine implements the Cardigann definition execution engine: search template rendering, HTTP calls, row/field extraction via selectors, post-processing filter application, and normalized release construction.
Package engine implements the Cardigann definition execution engine: search template rendering, HTTP calls, row/field extraction via selectors, post-processing filter application, and normalized release construction.
Package httpclient provides the per-indexer HTTP client: persistent cookies (SQLite), rate limiting based on `requestDelay`, optional proxy (HTTP/SOCKS5), and retries with exponential backoff on network/5xx errors.
Package httpclient provides the per-indexer HTTP client: persistent cookies (SQLite), rate limiting based on `requestDelay`, optional proxy (HTTP/SOCKS5), and retries with exponential backoff on network/5xx errors.
internal
httputil
Package httputil provides shared HTTP utilities between the engine and login packages to avoid duplicating common logic.
Package httputil provides shared HTTP utilities between the engine and login packages to avoid duplicating common logic.
Package login implements the Cardigann authentication engine: supported methods are `form`, `cookie`, `get`, and `oneurl`.
Package login implements the Cardigann authentication engine: supported methods are `form`, `cookie`, `get`, and `oneurl`.
Package selector provides a common abstraction for the different Cardigann extraction modes (CSS for HTML, JSON path for JSON, XML via etree).
Package selector provides a common abstraction for the different Cardigann extraction modes (CSS for HTML, JSON path for JSON, XML via etree).
Package template provides the Cardigann template rendering engine (`{{ .Keywords }}`, `{{ if .Config.xxx }}...{{ end }}`, etc.), which is natively compatible with Go text/template syntax.
Package template provides the Cardigann template rendering engine (`{{ .Keywords }}`, `{{ if .Config.xxx }}...{{ end }}`, etc.), which is natively compatible with Go text/template syntax.
filters
Package filters implements the Cardigann post-processing filter pipeline (distinct from the template engine) applied to extracted field values (`fields.<name>.filters`).
Package filters implements the Cardigann post-processing filter pipeline (distinct from the template engine) applied to extracted field values (`fields.<name>.filters`).
Package torznab generates Torznab-compatible XML responses (https://torznab.github.io/schemas/2015/feed) for interoperability with clients like Sonarr/Radarr/Prowlarr.
Package torznab generates Torznab-compatible XML responses (https://torznab.github.io/schemas/2015/feed) for interoperability with clients like Sonarr/Radarr/Prowlarr.

Jump to

Keyboard shortcuts

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