Compare commits
5 Commits
2502611a11
...
f43eb60b93
Author | SHA1 | Date |
---|---|---|
|
f43eb60b93 | |
|
cbeffb0738 | |
|
51c78bb82f | |
|
5ba1cfd33c | |
|
357c3d787e |
BIN
electricboogaloo
BIN
electricboogaloo
Binary file not shown.
78
main.go
78
main.go
|
@ -1,7 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/andreykaipov/goobs"
|
||||
"github.com/andreykaipov/goobs/api/requests/inputs"
|
||||
|
@ -9,47 +11,71 @@ import (
|
|||
"github.com/andreykaipov/goobs/api/typedefs"
|
||||
)
|
||||
|
||||
/* TODO:
|
||||
1. Set password with a flag instead of text in the code
|
||||
2. Loop output
|
||||
3. Change Panic(err) to code that doesn't crash the program if it fails
|
||||
/*
|
||||
TODO:
|
||||
|
||||
1. Color backdrop to album cover (some sort of sampling?)
|
||||
2. Transition effect when swapping songs
|
||||
3. Has/Get code in parse could probably be done with an interface instead? (is it worth it?)
|
||||
4. Document functions
|
||||
*/
|
||||
var password string
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&password, "p", "", "your obs websocket password")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func main() {
|
||||
// change this password lol!
|
||||
client, err := goobs.New("localhost:4455", goobs.WithPassword("lwihuN0OUVTMeCMM"))
|
||||
sleepTime := 1.0
|
||||
client, err := goobs.New("localhost:4455", goobs.WithPassword(password))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatalf("Authentication failed, password %v absent or incorrect.", password)
|
||||
}
|
||||
defer client.Disconnect()
|
||||
params := sceneitems.NewGetSceneItemListParams().WithSceneName("cmus")
|
||||
scil, err := client.SceneItems.GetSceneItemList(params)
|
||||
|
||||
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()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
artist, err := getAttribute(out, "tag artist ", "tag albumartist ", "tag composer ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
title, err := getAttribute(out, "tag title ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
album, err := getAttribute(out, "tag album ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatalf("%v\nCmus is likely not running.", err.Error())
|
||||
}
|
||||
path, err := getAttribute(out, "file ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
var prevPath string
|
||||
for {
|
||||
out, err = CmusRemoteOutput()
|
||||
if err != nil {
|
||||
log.Fatalf("%v\nCmus is likely not running.", err.Error())
|
||||
}
|
||||
path, err = getAttribute(out, "file ")
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
if path != prevPath {
|
||||
artist, err := getAttribute(out, "tag artist ", "tag albumartist ", "tag composer ")
|
||||
if err != nil {
|
||||
log.Printf("%v does not have an artist listed.", path)
|
||||
artist = "Unknown"
|
||||
}
|
||||
title, err := getAttribute(out, "tag title ")
|
||||
if err != nil {
|
||||
log.Printf("%v does not have an title listed.", path)
|
||||
title = "Unknown"
|
||||
}
|
||||
album, err := getAttribute(out, "tag album ")
|
||||
if err != nil {
|
||||
log.Printf("%v does not have an album listed.", path)
|
||||
album = "Single"
|
||||
}
|
||||
|
||||
art, err := retrieveArt(path)
|
||||
artFile, err := writeArtFile(art)
|
||||
for i := range scil.SceneItems {
|
||||
|
@ -67,6 +93,10 @@ func main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
prevPath = path
|
||||
}
|
||||
}
|
||||
|
||||
func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value string, key string) {
|
||||
params := inputs.NewSetInputSettingsParams().WithInputName(sI.SourceName).WithInputUuid(sI.SourceUuid)
|
||||
|
@ -74,6 +104,8 @@ func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value string, key
|
|||
params.InputSettings[key] = value
|
||||
_, err := client.Inputs.SetInputSettings(params)
|
||||
if err != nil {
|
||||
// i should probably forcefully create the item element missing, but
|
||||
// this is fine for personal use.
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue