go package to browse Plex server / players with GDM.
Based on the work, and with the help of Tobias Hieta [email protected]
To install the gdmbrowser binary run, including the ...
at the end
go get github.com/cnf/go-gdm/...
If you have $GOPATH/bin
in your path, you can then run gdmbrowser -h
func GetPlayers() ([]*GDMMessage, error)
func GetPlayer(name string) (*GDMMessage, error)
func GetServers() ([]*GDMMessage, error)
func GetServer(name string) (*GDMMessage, error)
func WatchPlayers(freq int) (chan *GDMWatcher, error)
func WatchServers(freq int) (chan *GDMWatcher, error)
type GDMMessage struct {
Address *net.UDPAddr
Added bool
Props map[string]string
}
type GDMWatcher struct {
Watch chan *GDMMessage
closer chan bool
}
func (w *GDMWatcher) Close()
box, err := gdm.GetServer("someName")
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Printf("%# v\n", box.Props["Name"])
}
w, cerr := gdm.WatchServers(5)
if cerr != nil {
// Error handling
} else {
i := 0
fmt.Printf("%# v\n", w)
fmt.Println("================")
for gdm := range w.Watch {
fmt.Printf("%02d ++++++++++++++\n", i)
fmt.Printf("%# v\n", gdm)
i++
if i >= 10 {
w.Close() // Call close to quit to clean up.
}
}
}