more helpful errors
This commit is contained in:
parent
357c3d787e
commit
5ba1cfd33c
BIN
electricboogaloo
BIN
electricboogaloo
Binary file not shown.
33
main.go
33
main.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -10,43 +11,51 @@ import (
|
||||||
"github.com/andreykaipov/goobs/api/typedefs"
|
"github.com/andreykaipov/goobs/api/typedefs"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* TODO:
|
/*
|
||||||
|
TODO:
|
||||||
|
|
||||||
1. Set password with a flag instead of text in the code
|
1. Set password with a flag instead of text in the code
|
||||||
3. Change Panic(err) to code that doesn't crash the program if it fails
|
|
||||||
4. Document functions
|
4. Document functions
|
||||||
*/
|
*/
|
||||||
|
var password string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.StringVar(&password, "p", "", "your obs websocket password")
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// change this password lol!
|
// change this password lol!
|
||||||
sleepTime := 2.0
|
sleepTime := 1.0
|
||||||
client, err := goobs.New("localhost:4455", goobs.WithPassword("lwihuN0OUVTMeCMM"))
|
client, err := goobs.New("localhost:4455", goobs.WithPassword(password))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatalf("Authentication failed, password %v absent or incorrect.", password)
|
||||||
}
|
}
|
||||||
defer client.Disconnect()
|
defer client.Disconnect()
|
||||||
params := sceneitems.NewGetSceneItemListParams().WithSceneName("cmus")
|
params := sceneitems.NewGetSceneItemListParams().WithSceneName("cmus")
|
||||||
scil, err := client.SceneItems.GetSceneItemList(params)
|
scil, err := client.SceneItems.GetSceneItemList(params)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
// i should force create the scene if it does not exist. but this is solely for me.
|
||||||
|
// failing in this way is probably smarter since it forces to arrange the scene how i want it.
|
||||||
|
log.Fatalf("Expecting a scene named \"cmus\", but the scene was not found.\n%v", err.Error())
|
||||||
}
|
}
|
||||||
out, err := CmusRemoteOutput()
|
out, err := CmusRemoteOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatalf("%v\nCmus is likely not running.", err.Error())
|
||||||
}
|
}
|
||||||
path, err := getAttribute(out, "file ")
|
path, err := getAttribute(out, "file ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
var prevPath string
|
var prevPath string
|
||||||
for {
|
for {
|
||||||
out, err = CmusRemoteOutput()
|
out, err = CmusRemoteOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatalf("%v\nCmus is likely not running.", err.Error())
|
||||||
}
|
}
|
||||||
path, err = getAttribute(out, "file ")
|
path, err = getAttribute(out, "file ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
if path != prevPath {
|
if path != prevPath {
|
||||||
artist, err := getAttribute(out, "tag artist ", "tag albumartist ", "tag composer ")
|
artist, err := getAttribute(out, "tag artist ", "tag albumartist ", "tag composer ")
|
||||||
|
@ -93,6 +102,8 @@ func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value string, key
|
||||||
params.InputSettings[key] = value
|
params.InputSettings[key] = value
|
||||||
_, err := client.Inputs.SetInputSettings(params)
|
_, err := client.Inputs.SetInputSettings(params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// i should probably forcefully create the item element missing, but
|
||||||
|
// this is fine for personal use.
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue