openwebif

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package openwebif provides a client for interacting with Enigma2 OpenWebIF API.

Package openwebif provides OpenWebIF client functionality for Enigma2 receivers.

Package openwebif provides OpenWebIF client functionality for Enigma2 receivers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEnabled added in v1.2.0

func IsEnabled() bool

IsEnabled checks if smart stream detection is enabled. Default: enabled for automatic OSCam Streamrelay detection Can be disabled with XG2G_SMART_STREAM_DETECTION=false

func PiconURL

func PiconURL(owiBase, sref string) string

PiconURL generates the URL for a channel's picon image based on the service reference.

func StreamURL

func StreamURL(base, ref, name string) (string, error)

StreamURL constructs a streaming URL from base URL and service reference. Preserved helper that now uses New, so ENV variables take effect. Deprecated: Use client.StreamURL(ctx, ref, name) for proper context propagation.

Types

type BouquetsResponse added in v1.5.0

type BouquetsResponse struct {
	Services [][]interface{} `json:"services"`
}

BouquetsResponse matches OpenWebIF API structure.

type Cacher added in v1.7.0

type Cacher interface {
	Get(key string) (any, bool)
	Set(key string, value any, ttl time.Duration)
	Delete(key string)
	Clear()
}

Cacher provides caching capabilities for OpenWebIF requests. This interface allows for different cache implementations (memory, Redis, etc.).

type Client

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

Client is an OpenWebIF HTTP client for communicating with Enigma2 receivers.

func New

func New(base string) *Client

New creates a new OpenWebIF client with the given options.

func NewWithPort

func NewWithPort(base string, streamPort int, opts Options) *Client

NewWithPort creates a new OpenWebIF client with a specific port.

func (*Client) Bouquets

func (c *Client) Bouquets(ctx context.Context) (map[string]string, error)

Bouquets retrieves all available bouquets from the receiver.

func (*Client) GetBouquetEPG

func (c *Client) GetBouquetEPG(ctx context.Context, bouquetRef string, days int) ([]EPGEvent, error)

GetBouquetEPG fetches EPG events for an entire bouquet

func (*Client) GetEPG

func (c *Client) GetEPG(ctx context.Context, sRef string, days int) ([]EPGEvent, error)

GetEPG retrieves EPG data for a specific service reference over specified days

func (*Client) Services

func (c *Client) Services(ctx context.Context, bouquetRef string) ([][2]string, error)

Services retrieves all services for a given bouquet.

func (*Client) StreamURL

func (c *Client) StreamURL(ctx context.Context, ref, name string) (string, error)

StreamURL builds a streaming URL for the given service reference. Context is used for smart stream detection and tracing.

type ClientInterface

type ClientInterface interface {
	Bouquets(ctx context.Context) (map[string]string, error)
	Services(ctx context.Context, bouquetRef string) ([][2]string, error)
	StreamURL(ctx context.Context, ref, name string) (string, error)
}

ClientInterface defines the subset used by other packages and tests.

type EPGEvent

type EPGEvent struct {
	ID          int    `json:"id"` // Changed from string to int
	Title       string `json:"title"`
	Description string `json:"shortdesc"`
	LongDesc    string `json:"longdesc"`
	Begin       int64  `json:"begin_timestamp"`
	Duration    int64  `json:"duration_sec"`
	SRef        string `json:"sref"`
}

EPGEvent represents a single programme entry from OpenWebIF EPG API

type EPGResponse

type EPGResponse struct {
	Events []EPGEvent `json:"events"`
	Result bool       `json:"result"`
}

EPGResponse represents the OpenWebIF EPG API response structure

type MockServer added in v1.5.0

type MockServer struct {
	*httptest.Server
	// contains filtered or unexported fields
}

MockServer provides a configurable OpenWebIF mock server for testing.

func NewMockServer added in v1.5.0

func NewMockServer() *MockServer

NewMockServer creates a new OpenWebIF mock server.

func (*MockServer) AddBouquet added in v1.5.0

func (m *MockServer) AddBouquet(ref, name string)

AddBouquet adds a bouquet to the mock server.

func (*MockServer) AddEPGEvent added in v1.5.0

func (m *MockServer) AddEPGEvent(serviceRef string, event EPGEvent)

AddEPGEvent adds an EPG event for a service.

func (*MockServer) AddService added in v1.5.0

func (m *MockServer) AddService(bouquetRef, serviceRef, serviceName string)

AddService adds a service to a bouquet.

func (*MockServer) Reset added in v1.5.0

func (m *MockServer) Reset()

Reset clears all mock data and resets to defaults.

func (*MockServer) SetDefaultData added in v1.5.0

func (m *MockServer) SetDefaultData()

SetDefaultData sets up realistic test data.

func (*MockServer) SetDelay added in v1.5.0

func (m *MockServer) SetDelay(endpoint string, delayMS int)

SetDelay sets an artificial delay (in milliseconds) for an endpoint.

func (*MockServer) SetFailures added in v1.5.0

func (m *MockServer) SetFailures(endpoint string, count int)

SetFailures sets the number of failures before success for an endpoint.

func (*MockServer) URL added in v1.5.0

func (m *MockServer) URL() string

URL returns the mock server's base URL.

type Options

type Options struct {
	Timeout               time.Duration
	ResponseHeaderTimeout time.Duration
	MaxRetries            int
	Backoff               time.Duration
	MaxBackoff            time.Duration
	Username              string
	Password              string

	// Caching options (v1.3.0+)
	Cache    Cacher        // Optional cache implementation
	CacheTTL time.Duration // Cache TTL (default: 5 minutes)
}

Options configures the OpenWebIF client behavior.

type ServicesResponse added in v1.5.0

type ServicesResponse struct {
	Services []map[string]interface{} `json:"services"`
}

ServicesResponse matches OpenWebIF API structure.

type StreamDetector added in v1.2.0

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

StreamDetector handles smart detection of optimal stream endpoints.

func NewStreamDetector added in v1.2.0

func NewStreamDetector(receiverHost string, logger zerolog.Logger) *StreamDetector

NewStreamDetector creates a new smart stream detector.

func (*StreamDetector) ClearCache added in v1.2.0

func (sd *StreamDetector) ClearCache()

ClearCache clears all cached stream detection results.

func (*StreamDetector) DetectBatch added in v1.2.0

func (sd *StreamDetector) DetectBatch(ctx context.Context, services [][2]string) (map[string]*StreamInfo, error)

DetectBatch detects optimal stream URLs for multiple services in parallel.

func (*StreamDetector) DetectStreamURL added in v1.2.0

func (sd *StreamDetector) DetectStreamURL(ctx context.Context, serviceRef, channelName string) (*StreamInfo, error)

DetectStreamURL determines the optimal stream URL for a given service reference. It tests multiple endpoints and returns the best working option.

type StreamInfo added in v1.2.0

type StreamInfo struct {
	URL          string    // The working stream URL
	Port         int       // Port used (8001, 17999, or proxy port)
	SupportsHEAD bool      // Whether the endpoint supports HEAD requests
	UseProxy     bool      // Whether to use the integrated proxy
	TestedAt     time.Time // When this was last tested
	TestError    error     // Last test error (if any)
}

StreamInfo contains information about a tested stream endpoint.

Jump to

Keyboard shortcuts

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