roku

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Roku External Control Protocol Client

GoDoc Go Report Card

This package provides a Go library for the Roku External Control Protocol

Installation

go get github.com/alexhowarth/go-roku

Usage

// search for a Roku device on the local network
roku.Search()

// build a client
client := roku.NewClient("http://192.168.0.21:8060")

// build a client, overriding the default http.Client
httpClient := &http.Client{} // customise as required
client := roku.NewClient("http://192.168.0.21:8060", WithHttpClient(httpClient))

// information about the device
info, err := client.DeviceInfo()

// the active app
app, err := client.ActiveApp()

// all apps on the device
apps, err := client.Apps()

// launch the YouTube app with arguments
youtube := "837"
err := client.Launch(youtube, "yk8yvt5lWVc", "")

Command line tool

This package contains the command line tool roku-cli

To install and use it:

$ go install ./roku-cli
$ roku-cli --help

There are also pre-built binaries for various architectures here.

To extract certain data from the output, you might use jq.

API

Documentation for the API can be found at https://developer.roku.com

Documentation

Overview

Package roku provides a Roku External Control Protocol Client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(timeout int) (*[]ssdp.Service, error)

Search uses SSDP to discover all Roku devices on the local network

Types

type ActiveApp

type ActiveApp struct {
	App         string `xml:"app"`
	Screensaver struct {
		Text    string `xml:",chardata"`
		ID      int    `xml:"id,attr"`
		Type    string `xml:"type,attr"`
		Version string `xml:"version,attr"`
	} `xml:"screensaver"`
}

ActiveApp details the app that is currently active on the device

type App

type App struct {
	Text    string `xml:",chardata"`
	ID      int    `xml:"id,attr"`
	Type    string `xml:"type,attr"`
	Version string `xml:"version,attr"`
}

App represents an app installed on the device

type Apps

type Apps struct {
	Apps []*App `xml:"app"`
}

Apps is a slice of App

func (*Apps) FindByID

func (a *Apps) FindByID(id int) (*App, bool)

FindById searches for an app by ID Returns the app and true if found

func (*Apps) FindByName

func (a *Apps) FindByName(text string) (*App, bool)

FindByName searches for an app by name Returns the app and true if found

type Client added in v0.0.2

type Client struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

Client for Roku ECP

func NewClient

func NewClient(addr string, opts ...ClientOption) (*Client, error)

NewClient constructs a Client

func (*Client) ActiveApp added in v0.0.2

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

ActiveApp returns the current app in use on the device

func (*Client) Apps added in v0.0.2

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

Apps returns information on the apps installed on the device

func (*Client) DeviceInfo added in v0.0.2

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

DeviceInfo returns info on the device

func (*Client) Launch added in v0.0.2

func (c *Client) Launch(channelID string, contentID string, mediaType string) error

Launch a channel on the device

type ClientOption

type ClientOption func(*Client)

ClientOption is a type that can be passed to the NewClient constructor for configuration

func WithHttpClient

func WithHttpClient(hc *http.Client) ClientOption

WithHttpClient is a ClientOption that swaps out the default http.Client This is useful for testing/customising the client

type DeviceInfo

type DeviceInfo struct {
	Udn                      string `xml:"udn"`
	SerialNumber             string `xml:"serial-number"`
	DeviceID                 string `xml:"device-id"`
	AdvertisingID            string `xml:"advertising-id"`
	VendorName               string `xml:"vendor-name"`
	ModelName                string `xml:"model-name"`
	ModelNumber              string `xml:"model-number"`
	ModelRegion              string `xml:"model-region"`
	IsTv                     bool   `xml:"is-tv"`
	IsStick                  bool   `xml:"is-stick"`
	UiResolution             string `xml:"ui-resolution"`
	SupportsEthernet         bool   `xml:"supports-ethernet"`
	WifiMac                  string `xml:"wifi-mac"`
	WifiDriver               string `xml:"wifi-driver"`
	HasWifiExtender          bool   `xml:"has-wifi-extender"`
	HasWifi5GSupport         bool   `xml:"has-wifi-5G-support"`
	CanUseWifiExtender       bool   `xml:"can-use-wifi-extender"`
	NetworkType              string `xml:"network-type"`
	NetworkName              string `xml:"network-name"`
	FriendlyDeviceName       string `xml:"friendly-device-name"`
	FriendlyModelName        string `xml:"friendly-model-name"`
	DefaultDeviceName        string `xml:"default-device-name"`
	UserDeviceName           string `xml:"user-device-name"`
	UserDeviceLocation       string `xml:"user-device-location"`
	BuildNumber              string `xml:"build-number"`
	SoftwareVersion          string `xml:"software-version"`
	SoftwareBuild            string `xml:"software-build"`
	SecureDevice             bool   `xml:"secure-device"`
	Language                 string `xml:"language"`
	Country                  string `xml:"country"`
	Locale                   string `xml:"locale"`
	TimeZoneAuto             bool   `xml:"time-zone-auto"`
	TimeZone                 string `xml:"time-zone"`
	TimeZoneName             string `xml:"time-zone-name"`
	TimeZoneTz               string `xml:"time-zone-tz"`
	TimeZoneOffset           string `xml:"time-zone-offset"`
	ClockFormat              string `xml:"clock-format"`
	Uptime                   string `xml:"uptime"`
	PowerMode                string `xml:"power-mode"`
	SupportsSuspend          bool   `xml:"supports-suspend"`
	SupportsFindRemote       bool   `xml:"supports-find-remote"`
	FindRemoteIsPossible     bool   `xml:"find-remote-is-possible"`
	SupportsAudioGuide       bool   `xml:"supports-audio-guide"`
	SupportsRva              bool   `xml:"supports-rva"`
	DeveloperEnabled         bool   `xml:"developer-enabled"`
	KeyedDeveloperID         string `xml:"keyed-developer-id"`
	SearchEnabled            bool   `xml:"search-enabled"`
	SearchChannelsEnabled    bool   `xml:"search-channels-enabled"`
	VoiceSearchEnabled       bool   `xml:"voice-search-enabled"`
	NotificationsEnabled     bool   `xml:"notifications-enabled"`
	NotificationsFirstUse    bool   `xml:"notifications-first-use"`
	SupportsPrivateListening bool   `xml:"supports-private-listening"`
	HeadphonesConnected      bool   `xml:"headphones-connected"`
	SupportsEcsTextedit      bool   `xml:"supports-ecs-textedit"`
	SupportsEcsMicrophone    bool   `xml:"supports-ecs-microphone"`
	SupportsWakeOnWlan       bool   `xml:"supports-wake-on-wlan"`
	HasPlayOnRoku            bool   `xml:"has-play-on-roku"`
	HasMobileScreensaver     bool   `xml:"has-mobile-screensaver"`
	SupportURL               string `xml:"support-url"`
	GrandcentralVersion      string `xml:"grandcentral-version"`
	TrcVersion               string `xml:"trc-version"`
	TrcChannelVersion        string `xml:"trc-channel-version"`
	DavinciVersion           string `xml:"davinci-version"`
}

DeviceInfo provides detailed information about the device the client is connected to

Directories

Path Synopsis
Package main provides a command line interface to go-roku
Package main provides a command line interface to go-roku
cmd

Jump to

Keyboard shortcuts

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