playlist

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPlaylistSourceNotFound           = errors.New("playlist source not found")
	ErrPlaylistSourceOrderDrift         = errors.New("playlist source set changed")
	ErrPrimaryPlaylistSourceDelete      = errors.New("primary playlist source cannot be deleted")
	ErrPrimaryPlaylistSourceOrderChange = errors.New("primary playlist source cannot be removed from reorder set")
	ErrNoEnabledPlaylistSources         = errors.New("at least one enabled playlist source is required")
)

Functions

func CanonicalPlaylistSourceName added in v1.1.0

func CanonicalPlaylistSourceName(raw string) string

CanonicalPlaylistSourceName returns the normalized comparison key used for source-name uniqueness checks across config, API, and store mutation paths.

func CanonicalPlaylistSourceURL added in v1.1.0

func CanonicalPlaylistSourceURL(raw string) string

CanonicalPlaylistSourceURL returns the normalized comparison key used for source URL uniqueness checks across config, API, and store mutation paths.

Canonicalization rules: - trim surrounding whitespace - lowercase scheme and host - preserve path/query/fragment semantics - if parsing fails, fall back to lowercased raw string

Types

type CatalogStore

type CatalogStore interface {
	UpsertPlaylistItems(ctx context.Context, items []Item) error
}

CatalogStore persists playlist catalog items.

type Fetcher

type Fetcher interface {
	FetchAndParse(ctx context.Context, playlistURL string) ([]Item, error)
}

Fetcher fetches and parses playlists from an external source.

type Group

type Group struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

Group represents a playlist group with item count.

type Item

type Item struct {
	ItemKey            string
	ChannelKey         string
	Name               string
	Group              string
	StreamURL          string
	TVGID              string
	PlaylistSourceID   int64
	PlaylistSourceName string
	Attrs              map[string]string
	FirstSeenAt        int64
	LastSeenAt         int64
	Active             bool
}

Item is a normalized playlist entry used by catalog and favorites workflows.

type ItemStream

type ItemStream func(yield func(Item) error) error

ItemStream incrementally emits playlist items to a callback.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager fetches and parses remote playlists.

func NewManager

func NewManager(client *http.Client) *Manager

func (*Manager) FetchAndParse

func (m *Manager) FetchAndParse(ctx context.Context, playlistURL string) ([]Item, error)

func (*Manager) FetchAndParseEach

func (m *Manager) FetchAndParseEach(ctx context.Context, playlistURL string, onItem func(Item) error) (int, error)

FetchAndParseEach fetches a remote playlist and emits normalized entries incrementally.

func (*Manager) Parse

func (m *Manager) Parse(r io.Reader) ([]Item, error)

func (*Manager) ParseEach

func (m *Manager) ParseEach(r io.Reader, onItem func(Item) error) (int, error)

ParseEach parses playlist content and emits normalized entries incrementally.

type PlaylistSource added in v1.1.0

type PlaylistSource struct {
	SourceID    int64  `json:"source_id"`
	SourceKey   string `json:"source_key"`
	Name        string `json:"name"`
	PlaylistURL string `json:"playlist_url"`
	TunerCount  int    `json:"tuner_count"`
	Enabled     bool   `json:"enabled"`
	OrderIndex  int    `json:"order_index"`
	CreatedAt   int64  `json:"created_at"`
	UpdatedAt   int64  `json:"updated_at"`
}

PlaylistSource describes one configured playlist ingest source.

type PlaylistSourceBulkUpdate added in v1.1.0

type PlaylistSourceBulkUpdate struct {
	SourceID    int64
	Name        string
	PlaylistURL string
	TunerCount  int
	Enabled     bool
}

PlaylistSourceBulkUpdate carries one ordered source mutation entry for atomic multi-source update operations.

type PlaylistSourceCreate added in v1.1.0

type PlaylistSourceCreate struct {
	Name        string `json:"name"`
	PlaylistURL string `json:"playlist_url"`
	TunerCount  int    `json:"tuner_count"`
	Enabled     *bool  `json:"enabled,omitempty"`
}

PlaylistSourceCreate carries create arguments for one playlist source.

type PlaylistSourceUpdate added in v1.1.0

type PlaylistSourceUpdate struct {
	Name        *string `json:"name,omitempty"`
	PlaylistURL *string `json:"playlist_url,omitempty"`
	TunerCount  *int    `json:"tuner_count,omitempty"`
	Enabled     *bool   `json:"enabled,omitempty"`
}

PlaylistSourceUpdate carries mutable source fields.

type Query

type Query struct {
	SourceIDs   []int64
	Group       string
	GroupNames  []string
	Search      string
	SearchRegex bool
	Limit       int
	Offset      int
}

Query controls catalog filtering and pagination.

type Refresher

type Refresher struct {
	// contains filtered or unexported fields
}

Refresher coordinates fetch + persist operations.

func NewRefresher

func NewRefresher(fetcher Fetcher, store CatalogStore, logger ...*slog.Logger) *Refresher

func (*Refresher) Refresh

func (r *Refresher) Refresh(ctx context.Context, playlistURL string) (int, error)

func (*Refresher) RefreshForSource added in v1.1.0

func (r *Refresher) RefreshForSource(ctx context.Context, source PlaylistSource) (int, error)

RefreshForSource refreshes one playlist source into source-scoped catalog storage.

type SourceCatalogStore added in v1.1.0

type SourceCatalogStore interface {
	UpsertPlaylistItemsForSource(ctx context.Context, sourceID int64, items []Item) error
}

SourceCatalogStore persists playlist items for one playlist source.

type StreamingCatalogStore

type StreamingCatalogStore interface {
	UpsertPlaylistItemsStream(ctx context.Context, stream ItemStream) (int, error)
}

StreamingCatalogStore persists playlist items from a streaming source.

type StreamingFetcher

type StreamingFetcher interface {
	FetchAndParseEach(ctx context.Context, playlistURL string, onItem func(Item) error) (int, error)
}

StreamingFetcher fetches and parses playlists incrementally.

type StreamingSourceCatalogStore added in v1.1.0

type StreamingSourceCatalogStore interface {
	UpsertPlaylistItemsStreamForSource(ctx context.Context, sourceID int64, stream ItemStream) (int, error)
}

StreamingSourceCatalogStore persists playlist items incrementally for one playlist source.

Jump to

Keyboard shortcuts

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