Help us shape the future of Go! Take the 2026 Go Developer Survey

ids

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package ids provides stable, stateless protocol identifiers.

Index

Constants

View Source
const PersonalViewBit int64 = 1 << 62

PersonalViewBit marks a view id that belongs to one viewer's home row rather than a library section. Library ids are small positive integers and never set this bit. The id stays stable for a viewer and row identity.

Variables

View Source
var ErrInvalid = errors.New("invalid identifier")

Functions

func Decimal

func Decimal(id int64) string

func FormatStremio

func FormatStremio(id StremioID) (string, error)

FormatStremio encodes an external identifier and optional episode in the same format accepted by ParseStremio. IMDb identifiers retain leading zeros.

func GUID

func GUID(kind Kind, id int64) (string, error)

GUID encodes a signed identifier in a kind-specific 128-bit namespace.

func IsSeries

func IsSeries(key core.RatingKey) bool

IsSeries reports whether a decoded item key represents a series.

func ParseDecimal

func ParseDecimal(value string) (int64, error)

func ParseGUID

func ParseGUID(kind Kind, value string) (int64, error)

ParseGUID accepts canonical dashed or undashed GUIDs and verifies the namespace.

func ParseRatingKeyGUID

func ParseRatingKeyGUID(value string) (core.RatingKey, error)

func PersonalView

func PersonalView(id int64) bool

PersonalView reports whether a decoded view id is a personalized home row.

func RatingKeyGUID

func RatingKeyGUID(key core.RatingKey) string

func StremioTMDBKey

func StremioTMDBKey(mediaType string, id StremioID) (core.RatingKey, error)

StremioTMDBKey maps a TMDB Stremio identifier to its neutral catalogue key. IMDb identifiers require the host's policy-checked external ID lookup.

func StringGUID

func StringGUID(kind Kind, value string) (string, error)

StringGUID maps opaque channel/programme IDs into distinct namespaces. It is deterministic but not reversible; resolution requires the host's viewer-filtered LiveTV lookup.

Types

type Codecs

type Codecs struct{ Allocator CompactAllocator }

func (Codecs) Compact

func (c Codecs) Compact(ctx context.Context, surface, kind, ref string) (int32, error)

func (Codecs) Decimal

func (Codecs) Decimal(id int64) string

func (Codecs) FormatStremio

func (Codecs) FormatStremio(id StremioID) (string, error)

func (Codecs) GUID

func (Codecs) GUID(kind Kind, id int64) (string, error)

func (Codecs) ParseDecimal

func (Codecs) ParseDecimal(value string) (int64, error)

func (Codecs) ParseGUID

func (Codecs) ParseGUID(kind Kind, value string) (int64, error)

func (Codecs) ParseRatingKeyGUID

func (Codecs) ParseRatingKeyGUID(value string) (core.RatingKey, error)

func (Codecs) ParseStremio

func (Codecs) ParseStremio(value string) (StremioID, error)

func (Codecs) RatingKeyGUID

func (Codecs) RatingKeyGUID(key core.RatingKey) string

func (Codecs) Resolve

func (c Codecs) Resolve(ctx context.Context, surface, kind string, id int32) (string, error)

func (Codecs) StringGUID

func (Codecs) StringGUID(kind Kind, value string) (string, error)

type CompactAllocator

type CompactAllocator interface {
	Compact(context.Context, string, string, string) (int32, error)
	Resolve(context.Context, string, string, int32) (string, error)
}

Codecs exposes stateless codecs to a frontend without retaining state.

type Kind

type Kind uint64

Kind separates identifiers for different entity classes.

const (
	Item Kind = iota + 1
	User
	Person
	View
	Genre
	Studio
	Session
	Playlist
	Channel
	Programme
)

type StremioID

type StremioID struct {
	Source          string
	ID              string
	Season, Episode int
	HasEpisode      bool
}

StremioID is an external TMDB or IMDb identifier with an optional episode. IMDb identifiers cannot be converted to RatingKey without a catalog lookup.

func ParseStremio

func ParseStremio(value string) (StremioID, error)

ParseStremio accepts tmdb:<id> or tt<digits>, optionally followed by :<season>:<episode>. TMDB type (movie or series) is supplied by the caller.

Jump to

Keyboard shortcuts

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