cair

package
v0.0.0-...-737e0a3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: ISC Imports: 11 Imported by: 0

Documentation

Overview

Package cair provides a client to version 24.1 of the Cinegy Air HTTP API as documented at https://open.cinegy.com/products/air/24.1/cinegy-air-http-api/.

Typical usage starts with creating a Client, then fetching the current playlist by calling Playlist on Client. For example, to print the names of all future items that are 3 minutes or less (e.g. station breaks):

client := &Client{http.DefaultClient, "http://air.example.com:5521")
playlist, err := client.Playlist("video")
if err != nil {
	// handle error...
}
for _, it := range playlist.Items {
	if it.ScheduledAt.Before(time.Now()) {
		continue
	}
	if it.Duration <= 3*time.Minute {
		fmt.Println(it.Name)
	}
}

Index

Constants

View Source
const DefaultPort = 5521

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client // http.DefaultClient if nil.
	// Root is a HTTP URL pointing to the root from the Air API is served.
	// If empty the client assumes the value "http://127.0.0.1:5521".
	Root string
}

Client is used to communicate with the Cinegy Air API.

func (*Client) Playlist

func (c *Client) Playlist(device string) (*Playlist, error)

Playlist retrieves the current Playlist for the named device. Supported names include:

  • "video"
  • "titler_0"
  • "logo"
  • "cg_[0-8]" e.g. cg_0, cg_1 ...
  • "cg_logo"
  • "gfx_[0-8]"
  • "audio"

For all supported names, see Cinegy Air 24.1 HTTP API, chapter 1.

func (*Client) Status

func (c *Client) Status() (*Status, error)

type Item

type Item struct {
	ID            string        `xml:"Id,attr"`
	Name          string        `xml:",attr"`
	Description   string        `xml:",attr"`
	ThirdPartyId  string        `xml:",attr"`
	SubtitleId    string        `xml:",attr"`
	EPGID         string        `xml:"EpgId,attr"`
	ProxyProgress string        `xml:",attr"`
	ScheduledAt   time.Time     `xml:",attr"`
	Duration      time.Duration `xml:",attr"`
	OutOfNetwork  string        `xml:",attr"`
}

func (*Item) EndTime

func (i *Item) EndTime() (time.Time, error)

EndTime calculates the time i should end by inspecting its start time and duration.

func (*Item) UnmarshalXML

func (i *Item) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error

type Playlist

type Playlist struct {
	XMLName struct{} `xml:"List"`
	Items   []Item   `xml:"Item"`
}

func ParsePlaylist

func ParsePlaylist(r io.Reader) (*Playlist, error)

ParsePlaylist parses a XML-encoded Playlist from r.

type Status

type Status struct {
	XMLName xml.Name `xml:"Status"`
	Active  struct {
		ID string `xml:"Id,attr"`
	}
	Cued struct {
		ID string `xml:"Id,attr"`
	}
	License struct {
		State string `xml:",attr"`
	}
	Output struct {
		State string `xml:",attr"`
	}
	Client clientStatus
}

Jump to

Keyboard shortcuts

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