loop output
This commit is contained in:
parent
2502611a11
commit
357c3d787e
BIN
electricboogaloo
BIN
electricboogaloo
Binary file not shown.
47
main.go
47
main.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/andreykaipov/goobs"
|
"github.com/andreykaipov/goobs"
|
||||||
"github.com/andreykaipov/goobs/api/requests/inputs"
|
"github.com/andreykaipov/goobs/api/requests/inputs"
|
||||||
|
@ -11,13 +12,13 @@ import (
|
||||||
|
|
||||||
/* 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
|
||||||
2. Loop output
|
|
||||||
3. Change Panic(err) to code that doesn't crash the program if it fails
|
3. Change Panic(err) to code that doesn't crash the program if it fails
|
||||||
4. Document functions
|
4. Document functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// change this password lol!
|
// change this password lol!
|
||||||
|
sleepTime := 2.0
|
||||||
client, err := goobs.New("localhost:4455", goobs.WithPassword("lwihuN0OUVTMeCMM"))
|
client, err := goobs.New("localhost:4455", goobs.WithPassword("lwihuN0OUVTMeCMM"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -33,23 +34,37 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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)
|
|
||||||
}
|
|
||||||
path, err := getAttribute(out, "file ")
|
path, err := getAttribute(out, "file ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
var prevPath string
|
||||||
|
for {
|
||||||
|
out, err = CmusRemoteOutput()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
path, err = getAttribute(out, "file ")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
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)
|
art, err := retrieveArt(path)
|
||||||
artFile, err := writeArtFile(art)
|
artFile, err := writeArtFile(art)
|
||||||
for i := range scil.SceneItems {
|
for i := range scil.SceneItems {
|
||||||
|
@ -66,6 +81,10 @@ func main() {
|
||||||
updateItem(client, scil.SceneItems[i], artFile, "file")
|
updateItem(client, scil.SceneItems[i], artFile, "file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||||
|
prevPath = path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value string, key string) {
|
func updateItem(client *goobs.Client, sI *typedefs.SceneItem, value string, key string) {
|
||||||
|
|
Loading…
Reference in New Issue