torznab

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package torznab implements Torznab/Newznab XML protocol types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPubDate

func FormatPubDate(dateStr string) string

FormatPubDate formats a time string for Torznab pubDate field (RFC1123Z). Handles RFC3339 dates, relative dates ("3 days", "1 week, 2 days"), and "now".

Types

type Caps

type Caps struct {
	XMLName    xml.Name       `xml:"caps"`
	Server     CapsServer     `xml:"server"`
	Limits     CapsLimits     `xml:"limits"`
	Searching  CapsSearching  `xml:"searching"`
	Categories CapsCategories `xml:"categories"`
}

Caps is the XML capabilities document.

func NewCaps

func NewCaps(title string, cats []CapsCategory, modes map[string][]string) Caps

NewCaps creates a capabilities document from category mappings and search modes.

type CapsCategories

type CapsCategories struct {
	Categories []CapsCategory `xml:"category"`
}

type CapsCategory

type CapsCategory struct {
	ID      string         `xml:"id,attr"`
	Name    string         `xml:"name,attr"`
	Subcats []CapsCategory `xml:"subcat,omitempty"`
}

type CapsLimits

type CapsLimits struct {
	Max     int `xml:"max,attr"`
	Default int `xml:"default,attr"`
}

type CapsSearchType

type CapsSearchType struct {
	Available       string `xml:"available,attr"`
	SupportedParams string `xml:"supportedParams,attr"`
}

type CapsSearching

type CapsSearching struct {
	Search      *CapsSearchType `xml:"search,omitempty"`
	TVSearch    *CapsSearchType `xml:"tv-search,omitempty"`
	MovieSearch *CapsSearchType `xml:"movie-search,omitempty"`
}

type CapsServer

type CapsServer struct {
	Title string `xml:"title,attr"`
}

type Channel

type Channel struct {
	Title string `xml:"title"`
	Items []Item `xml:"item"`
}

type Enclosure

type Enclosure struct {
	URL    string `xml:"url,attr"`
	Length int64  `xml:"length,attr"`
	Type   string `xml:"type,attr"`
}

type Feed

type Feed struct {
	XMLName   xml.Name `xml:"rss"`
	Version   string   `xml:"version,attr"`
	AtomNS    string   `xml:"xmlns:atom,attr,omitempty"`
	TorznabNS string   `xml:"xmlns:torznab,attr"`
	Channel   Channel  `xml:"channel"`
}

Feed is the Torznab RSS search results feed.

func NewFeed

func NewFeed(title string, items []Item) Feed

NewFeed creates a new search results feed.

type Item

type Item struct {
	Title     string
	GUID      string
	Link      string // detail page URL
	PubDate   string
	Size      int64
	Enclosure *Enclosure
	Attrs     map[string]string // torznab attributes (seeders, peers, etc.)
}

Item is a single search result. Custom XML marshaling is used to produce <torznab:attr> elements in the correct namespace.

func ResultToItem

func ResultToItem(r interface{ GetTitle() string }, baseURL string) Item

ResultToItem converts a scraper SearchResult to a Torznab Item.

func SearchResultToItem

func SearchResultToItem(title, guid, link, pubDate string, size int64, downloadURL string, seeders, leechers int, dvf, uvf float64, category string) Item

SearchResultToItem converts a scraper.SearchResult to a torznab.Item.

func (Item) MarshalXML

func (item Item) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML produces the Torznab-compatible XML for an Item.

Jump to

Keyboard shortcuts

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