roku

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 7 Imported by: 0

README

roku

Documentation

Roku ECP library written in Go

Inspired by https://github.com/ncmiller/roku-cli

The project started out aiming to essentially be a GoLang fork of roku-cli, adding in the options of VolumeUp and VolumeDown buttons.

It is now turning into a Roku ECP library, with accompanying CLI Roku Remote

Library

Installation
go get -u jonwillia.ms/roku

or use go mod

Example
package main

import (
  "jonwillia.ms/roku"
)

func main() {
  devices, err := roku.FindRokuDevices()
  if err != nil {
    panic(err)
  }
  r, err := roku.NewRemote(devices[0].Addr)
  if err != nil {
    panic(err)
  }
  err = r.VolumeUp()
  if err != nil {
    panic(err)
  }
  if r.Device.PowerMode == "PowerOn" {
    // ignoring errors for brevity
    r.PowerOff()
    r.Refresh()
  }
}

CLI

Installation
go get -u jonwillia.ms/roku
Usage
roku -ip 192.168.1.51

You can also simply run

roku

and it will search for Roku devices on the network (takes an extra 3 seconds).

Documentation

Overview

Package roku implements a library for interacting with Roku devices using the External Control Protocol (ECP) Example can be found at http://jonwillia.ms/roku/roku

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name string `xml:",chardata"`
	Id   string `xml:"id,attr"`
}

App holds the app name and corresponding id The ID is needed to install/open and app

type DeviceInfo

type DeviceInfo struct {
	XMLName                     xml.Name `xml:"device-info"`
	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"`
	ScreenSize                  string   `xml:"screen-size"`
	PanelId                     string   `xml:"panel-id"`
	TunerType                   string   `xml:"tuner-type"`
	SuuportsEthernet            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"`
	EthernetMac                 string   `xml:"ethernet-mac"`
	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              int      `xml:"time-zone-offset"`
	ClockFormat                 string   `xml:"clock-format"`
	Uptime                      int      `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"`
	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"`
	SupportsPrivateListeningDtv bool     `xml:"supports-private-listening-dtv"`
	SupportsWarmStandby         bool     `xml:"supports-warm-standby"`
	HeadphonesConnected         bool     `xml:"headphones-connected"`
	ExpertPqEnabled             string   `xml:"expert-pq-enabled"`
	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 is the information about the Roku The most useful fields are probably `PowerMode` (To know if device is On/Ready/etc) and maybe the Name and network information

type Format

type Format struct {
	Audio    string `xml:"audio,attr"`
	Captions string `xml:"captions,attr"`
	Drm      string `xml:"drm,attr"`
	Video    string `xml:"video,attr"`
}

type PlayerStatus

type PlayerStatus struct {
	XMLName  xml.Name `xml:"player"`
	Error    bool     `xml:"error,attr"`
	State    string   `xml:"state,attr"`
	Plugin   Plugin   `xml:"plugin"`
	Format   Format   `xml:"format"`
	Position string   `xml:"position"`
	IsLive   bool     `xml:"is_live"`
}

PlayerStatus holds the media status of the app currently running

type Plugin

type Plugin struct {
	Bandwidth string `xml:"bandwidth,attr"`
	Id        string `xml:"id,attr"`
	Name      string `xml:"name,attr"`
}

type Remote

type Remote struct {
	Addr   string
	Device *DeviceInfo
}

Remote is the base type for interacting with the Roku Device is populated when a `NewRemote` is called to create a new remote

func NewRemote

func NewRemote(addr string) (*Remote, error)

NewRemote sets up a remote to the given ip.

func (*Remote) ActiveApp

func (r *Remote) ActiveApp() (*App, error)

ActiveApp returns the app currently running

func (*Remote) Apps

func (r *Remote) Apps() ([]*App, error)

Apps will get all installed apps fromt he device

func (*Remote) Back

func (r *Remote) Back() error

Equivalent of pressing Back button on the remote

func (*Remote) Backspace

func (r *Remote) Backspace() error

Equivalent of pressing Backspace button on the remote

func (*Remote) ChannelDown

func (r *Remote) ChannelDown() error

Equivalent of pressing Channel Down button on the remote not available on all devices

func (*Remote) ChannelUp

func (r *Remote) ChannelUp() error

Equivalent of pressing Channel Up button on the remote not available on all devices

func (*Remote) DeviceInfo

func (r *Remote) DeviceInfo() (*DeviceInfo, error)

DeviceInfo shows the device info for connected device.

func (*Remote) Down

func (r *Remote) Down() error

Equivalent of pressing Down button on the remote

func (*Remote) Enter

func (r *Remote) Enter() error

Equivalent of pressing Enter button on the remote

func (*Remote) Fwd

func (r *Remote) Fwd() error

Equivalent of pressing Fwd button on the remote

func (*Remote) Home

func (r *Remote) Home() error

Equivalent of pressing Home button on the remote

func (*Remote) Info

func (r *Remote) Info() error

Equivalent of pressing Info button on the remote

func (*Remote) InputRune

func (r *Remote) InputRune(rn rune) error

func (*Remote) InputString

func (r *Remote) InputString(in string) error

Input sends a string of input (useful for things like filling a search box)

func (*Remote) Install

func (r *Remote) Install(app *App) error

Install will install the given app. Thie requres already knowing the App Id of the App you want to install

func (*Remote) InstantReplay

func (r *Remote) InstantReplay() error

Equivalent of pressing Instant Replay button on the remote

func (*Remote) Launch

func (r *Remote) Launch(app *App) error

Launch will launch a given App

func (*Remote) LaunchWithValues

func (r *Remote) LaunchWithValues(app *App, values url.Values) error

LaunchWithValues will launch a given App with exta arguments

func (*Remote) Left

func (r *Remote) Left() error

Equivalent of pressing Left button on the remote

func (*Remote) Play

func (r *Remote) Play() error

Equivalent of pressing Play button on the remote

func (*Remote) PlayerStatus

func (r *Remote) PlayerStatus() (*PlayerStatus, error)

PlayerStatus returns the media player state

func (*Remote) PowerOff

func (r *Remote) PowerOff() error

Equivalent of pressing Power button on the remote not available on all devices

func (*Remote) PowerOn

func (r *Remote) PowerOn() error

Equivalent of pressing Power button on the remote not available on all devices

func (*Remote) Refresh

func (r *Remote) Refresh() error

Refresh reloads the devince info on the remote

func (*Remote) Rev

func (r *Remote) Rev() error

Equivalent of pressing Rev button on the remote

func (*Remote) Right

func (r *Remote) Right() error

Equivalent of pressing Right button on the remote

func (*Remote) Search

func (r *Remote) Search() error

Equivalent of pressing Search button on the remote

func (*Remote) Select

func (r *Remote) Select() error

Equivalent of pressing Select button on the remote

func (*Remote) Up

func (r *Remote) Up() error

Equivalent of pressing Up button on the remote

func (*Remote) VolumeDown

func (r *Remote) VolumeDown() error

Equivalent of pressing Volume Down button on the remote not available on all devices

func (*Remote) VolumeMute

func (r *Remote) VolumeMute() error

Equivalent of pressing Mute button on the remote not available on all devices

func (*Remote) VolumeUp

func (r *Remote) VolumeUp() error

Equivalent of pressing Volume Up button on the remote not available on all devices

type RokuDevice

type RokuDevice struct {
	Addr string
	Name string
}

RokuDevice is returned by FindRokuDevices For convenience finding Roku's on the network

func FindRokuDevices

func FindRokuDevices() ([]*RokuDevice, error)

FindRokuDevices will do and SSDP search to find all Roku devices on the network

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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