Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{
BindAddr: "localhost",
Port: 8080,
LogLevel: "info",
}
DefaultOptions is an Options object with default values. For fields that aren't set here the zero value is the default value.
var ( // NotFound signals that the catalog/meta/stream was not found. // It leads to a "404 Not Found" response. NotFound = errors.New("Not found") )
Functions ¶
This section is empty.
Types ¶
type Addon ¶
type Addon struct {
// contains filtered or unexported fields
}
Addon represents a remote addon. You can create one with NewAddon() and then run it with Run().
func NewAddon ¶
func NewAddon(manifest Manifest, catalogHandlers map[string]CatalogHandler, streamHandlers map[string]StreamHandler, opts Options) (Addon, error)
NewAddon creates a new Addon object that can be started with Run(). A proper manifest must be supplied, but all but one handler can be nil in case you only want to handle specific requests and opts can be the zero value of Options.
type BehaviorHints ¶
type CatalogHandler ¶
type CatalogHandler func(id string) ([]MetaPreviewItem, error)
CatalogHandler is the callback for catalog requests for a specific type (like "movie"). The id parameter is the catalog ID that you specified yourself in the CatalogItem objects in the Manifest.
type CatalogItem ¶
type CatalogItem struct { Type string `json:"type"` ID string `json:"id"` Name string `json:"name"` // Optional Extra []ExtraItem `json:"extra,omitempty"` }
CatalogItem represents a catalog.
type Manifest ¶
type Manifest struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Version string `json:"version"` // One of the following is required // Note: Can only have one in code because of how Go (de-)serialization works //Resources []string `json:"resources,omitempty"` ResourceItems []ResourceItem `json:"resources,omitempty"` Types []string `json:"types"` Catalogs []CatalogItem `json:"catalogs"` // Optional IDprefixes []string `json:"idPrefixes,omitempty"` Background string `json:"background,omitempty"` // URL Logo string `json:"logo,omitempty"` // URL ContactEmail string `json:"contactEmail,omitempty"` BehaviorHints BehaviorHints `json:"behaviorHints,omitempty"` }
Manifest describes the capabilities of the addon. See https://github.com/Stremio/stremio-addon-sdk/blob/f6f1f2a8b627b9d4f2c62b003b251d98adadbebe/docs/api/responses/manifest.md
type MetaItem ¶
type MetaItem struct { ID string `json:"id"` Type string `json:"type"` Name string `json:"name"` // Optional Links []MetaLinkItem `json:"links,omitempty"` // For genres, director, cast, etc. Poster string `json:"poster,omitempty"` // URL PosterShape string `json:"posterShape,omitempty"` Background string `json:"background,omitempty"` // URL Logo string `json:"logo,omitempty"` // URL Description string `json:"description,omitempty"` ReleaseInfo string `json:"releaseInfo,omitempty"` IMDbRating string `json:"imdbRating,omitempty"` Released string `json:"released,omitempty"` // Must be ISO 8601, e.g. "2010-12-06T05:00:00.000Z" Videos []VideoItem `json:"videos,omitempty"` Runtime string `json:"runtime,omitempty"` Language string `json:"language,omitempty"` Country string `json:"country,omitempty"` Awards string `json:"awards,omitempty"` Website string `json:"website,omitempty"` // URL }
MetaItem represents a meta item and is meant to be used when info for a specific item was requested. See https://github.com/Stremio/stremio-addon-sdk/blob/f6f1f2a8b627b9d4f2c62b003b251d98adadbebe/docs/api/responses/meta.md
type MetaLinkItem ¶
type MetaLinkItem struct { Name string `json:"name"` Category string `json:"category"` URL string `json:"url"` // // URL. Can be "Meta Links" (see https://github.com/Stremio/stremio-addon-sdk/blob/f6f1f2a8b627b9d4f2c62b003b251d98adadbebe/docs/api/responses/meta.links.md) }
type MetaPreviewItem ¶
type MetaPreviewItem struct { ID string `json:"id"` Type string `json:"type"` Name string `json:"name"` Poster string `json:"poster"` // URL // Optional PosterShape string `json:"posterShape,omitempty"` // Optional, used for the "Discover" page sidebar Links []MetaLinkItem `json:"links,omitempty"` // For genres, director, cast, etc. IMDbRating string `json:"imdbRating,omitempty"` ReleaseInfo string `json:"releaseInfo,omitempty"` Description string `json:"description,omitempty"` }
MetaPreviewItem represents a meta preview item and is meant to be used within catalog responses. See https://github.com/Stremio/stremio-addon-sdk/blob/f6f1f2a8b627b9d4f2c62b003b251d98adadbebe/docs/api/responses/meta.md#meta-preview-object
type Options ¶
type Options struct { // The interface to bind to. // "0.0.0.0" to bind to all interfaces. "localhost" to *exclude* requests from other machines. // Default "localhost". BindAddr string // The port to listen on. // Default 8080. Port int // The log level. // Only logs with the same or a higher log level will be shown. // For example when you set it to "info", info, warn and error logs will be shown, but no debug logs. // Accepts "debug", "info", "warn" and "error". // Default "info". LogLevel string // URL to redirect to when someone requests the root of the handler instead of the manifest, catalog, stream etc. // When no value is set, it will lead to a "404 Not Found" response. // Default "". RedirectURL string // Flag for indicating whether requests should be logged. // Default false (meaning requests will be logged by default). DisableRequestLogging bool // Flag for indicating whether you want to expose URL handlers for the Go profiler. // The URLs are be the standard ones: "/debug/pprof/...". // Default false. Profiling bool // Duration of client/proxy-side cache for responses from the catalog endpoint. // Helps reducing number of requsts and transferred data volume to/from the server. // The result is not cached by the SDK on the server side, so if two *separate* users make a reqeust, // and no proxy cached the response, your CatalogHandler will be called twice. // Default 0. CacheAgeCatalogs time.Duration // Same as CacheAgeCatalogs, but for streams. CacheAgeStreams time.Duration // Flag for indicating to proxies whether they are allowed to cache responses from the catalog endpoint. // Default false. CachePublicCatalogs bool // Same as CachePublicCatalogs, but for streams. CachePublicStreams bool // Flag for indicating whether the "ETag" header should be set and the "If-None-Match" header checked. // Helps reducing the transferred data volume from the server even further. // Only makes sense when setting a non-zero CacheAgeCatalogs. // Leads to a slight computational overhead due to every CatalogHandler result being hashed. // Default false. HandleEtagCatalogs bool // Same as HandleEtagCatalogs, but for streams. HandleEtagStreams bool }
Options are the options that can be used to configure the addon.
type ResourceItem ¶
type StreamHandler ¶
type StreamHandler func(id string) ([]StreamItem, error)
StreamHandler is the callback for stream requests for a specific type (like "movie"). The id parameter can be for example an IMDb ID if your addon handles the "movie" type.
type StreamItem ¶
type StreamItem struct { // One of the following is required URL string `json:"url,omitempty"` // URL YoutubeID string `json:"ytId,omitempty"` InfoHash string `json:"infoHash,omitempty"` ExternalURL string `json:"externalUrl,omitempty"` // URL // Optional Title string `json:"title,omitempty"` // Usually used for stream quality FileIndex uint8 `json:"fileIdx,omitempty"` // Only when using InfoHash }
StreamItem represents a stream for a MetaItem. See https://github.com/Stremio/stremio-addon-sdk/blob/f6f1f2a8b627b9d4f2c62b003b251d98adadbebe/docs/api/responses/stream.md
type VideoItem ¶
type VideoItem struct { ID string `json:"id"` Title string `json:"title"` Released string `json:"released"` // Must be ISO 8601, e.g. "2010-12-06T05:00:00.000Z" // Optional Thumbnail string `json:"thumbnail,omitempty"` // URL Streams []StreamItem `json:"streams,omitempty"` Available bool `json:"available,omitempty"` Episode string `json:"episode,omitempty"` Season string `json:"season,omitempty"` Trailer string `json:"trailer,omitempty"` // Youtube ID Overview string `json:"overview,omitempty"` }