hbbtv

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package hbbtv provides HbbTV (Hybrid Broadcast Broadband TV) detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Match

type Match struct {
	Version string `json:"version"`
}

Match represents the result of a successful HbbTV detection. It mirrors the PHP behavior of returning a version string from isHbbTv().

type Option

type Option func(*Parser)

Option is a functional option for configuring Parser behavior.

type Parser

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

Parser parses a single user agent for HbbTV information. Created via ParserFactory.NewParser() - do not instantiate directly.

func (*Parser) IsHbbTv

func (p *Parser) IsHbbTv() string

IsHbbTv returns the parsed HbbTV version if detected, otherwise "". Mirrors PHP: DeviceDetector\Parser\Device\HbbTv::isHbbTv(): ?string

func (*Parser) Parse

func (p *Parser) Parse() *Match

Parse mirrors the PHP parser's parse() semantics at a high level: - only parse user agents containing HbbTV/SmartTvA - otherwise return nil

Note: For now this focuses on the behavior needed by the PHP unit test (isHbbTv). TV brand/model parsing from televisions.yml can be added on top.

type ParserFactory

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

ParserFactory holds pre-compiled matchers and creates Parser instances. Thread-safe for concurrent use - create once, use from multiple goroutines.

func NewParserFactory

func NewParserFactory(opts ...common.FactoryOption) (*ParserFactory, error)

NewParserFactory creates a factory with all regexes compiled once.

func (*ParserFactory) IsHbbTv

func (f *ParserFactory) IsHbbTv(ua string) string

IsHbbTv is a convenience method mirroring PHP's $parser->isHbbTv(). It returns the HbbTV version string if detected, otherwise "".

func (*ParserFactory) NewParser

func (f *ParserFactory) NewParser(ua string, opts ...Option) *Parser

NewParser creates a new Parser instance for parsing a single user agent.

Jump to

Keyboard shortcuts

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