Add Torznab indexer, bulk job/wishlist ops, and OpenAPI spec#3
Merged
Conversation
Three additions to bring gamarr's API to feature-parity with librarr for
non-book-specific functionality:
* Torznab/Newznab indexer (new internal/torznab package): gamarr can
now be added as a Torznab indexer in Prowlarr / Sonarr / other *arr
apps. /torznab/api?t=caps returns Newznab-style game categories
(1000-series Console, 4000-series PC); ?t=search runs the same 3-
source fan-out as /api/search and returns RSS results. /api alias is
the path Prowlarr probes during indexer discovery. TORZNAB_API_KEY
env var gates access when set; empty key disables the check.
* Bulk operations (new internal/api/bulk.go):
- POST /api/admin/bulk/retry — retry many failed jobs in one call;
empty body retries ALL failed jobs.
- POST /api/admin/bulk/cancel — cancel many active jobs; empty body
cancels ALL active jobs.
- POST /api/wishlist/bulk-delete — delete many wishlist items.
All three return per-id outcomes so AI/UI clients can show partial
successes. Hard cap of 500 ids per request.
* OpenAPI 3.1 spec (new internal/api/openapi.go embedded from
openapi.json): AI agents and tooling can introspect /api/openapi.json
to discover endpoints, request bodies, and response shapes without
prior knowledge of the codebase. 23 endpoints + 5 schemas documented.
The Torznab handler has 14 subtest assertions covering caps document
shape, API-key gating, probe-response shape (matches Prowlarr's
validator requirements), search invocation flow, category mapping per
platform slug, link-selection priority (magnet > download URL >
info-hash-synthesized magnet > detail-page GUID), unknown-function
error handling, and Host-header propagation in probes.
457 tests pass; go build / vet / test -race all clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three additions to bring gamarr's API to feature-parity with librarr for non-book-specific functionality:
What changed
Torznab indexer (
/torznab/api+/apialias)New
internal/torznabpackage implementing the Newznab/Torznab protocol:?t=capsreturns the capabilities document with game-specific categories (Newznab 1000-series Console + 4000-series PC, with subcategories for NDS / PSP / Wii / Xbox / Xbox 360 / PS3 / Other / PC/Games)?t=search&q=<title>runs the same 3-source fan-out as/api/searchand returns RSS results, with per-platform category mapping intorznab:attr?t=searchwith no query returns a Prowlarr-validator-compliant placeholder (guid prefixedgamarr-placeholder-so downstream *arr apps don't grab it)/apialias is mounted exactly (not/api/*) so it doesn't shadow the JSON tree — it's the path Prowlarr probes during indexer discoveryTORZNAB_API_KEYenv var gates access via?apikey=when set; empty key disables the checkBulk operations
POST /api/admin/bulk/retry— empty body retries ALL failed jobs; otherwise retries the listedjob_idsPOST /api/admin/bulk/cancel— same shape, cancels active jobsPOST /api/wishlist/bulk-delete—{"ids": [...]}body requiredAll three return per-id outcomes (
{success, message}) so clients can show partial successes. Hard cap of 500 ids per request. Content-Type gating + size limits applied.OpenAPI 3.1 spec
GET /api/openapi.jsonreturns an embedded (//go:embed) OpenAPI 3.1 document describing 23 endpoints + 5 schemasapiKey(X-Api-Key header /?apikey=) andsession(cookie) security schemesTest plan
go build ./...,go vet ./...,go test -race -count=1 ./...all clean.go test -voutput.TORZNAB_API_KEY=test-torznab-key:/apialias works for Prowlarr'st=capsdiscovery probeopenapi: 3.1.0, 23 paths, 5 schemas)Backwards compatibility
Strictly additive. One new env var (
TORZNAB_API_KEY), four new routes. No existing route, response shape, or env var changed.