41 lines
925 B
Go
41 lines
925 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.dayanhub.com/sagi/subsonic-tui/internal/client"
|
||
|
"git.dayanhub.com/sagi/subsonic-tui/internal/config"
|
||
|
"git.dayanhub.com/sagi/subsonic-tui/internal/playback"
|
||
|
"git.dayanhub.com/sagi/subsonic-tui/internal/tui"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
// Create Client
|
||
|
c := client.NewClient(config.URL())
|
||
|
err := c.Authenticate(config.Username(), config.Password())
|
||
|
if err != nil {
|
||
|
// We need to show Login...
|
||
|
login := tui.NewLogin()
|
||
|
err := login.Run()
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
}
|
||
|
fmt.Println("Trying to login...")
|
||
|
c = client.NewClient(config.URL())
|
||
|
err = c.Authenticate(config.Username(), config.Password())
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
// Saving config - will result in adding new defaults to the file
|
||
|
config.SaveConfig()
|
||
|
playbackCtl := playback.NewController()
|
||
|
defer playbackCtl.Close()
|
||
|
|
||
|
tui := tui.NewPlayer(c, playbackCtl)
|
||
|
if err := tui.Run(); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|