2024-01-16 15:21:35 +00:00
|
|
|
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() {
|
|
|
|
defer client.ArtCache.Destroy()
|
|
|
|
// Create Client
|
|
|
|
subsonicClient := client.NewClient(config.URL())
|
2024-12-18 15:29:16 +00:00
|
|
|
|
2024-01-16 15:21:35 +00:00
|
|
|
err := subsonicClient.Authenticate(config.Username(), config.Password())
|
|
|
|
if err != nil {
|
|
|
|
// We need to show Login...
|
|
|
|
login := tui.NewLogin()
|
2024-12-18 15:29:16 +00:00
|
|
|
|
2024-01-16 15:21:35 +00:00
|
|
|
err := login.Run()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2024-12-18 15:29:16 +00:00
|
|
|
|
2024-01-16 15:21:35 +00:00
|
|
|
fmt.Println("Trying to login...")
|
2024-12-18 15:29:16 +00:00
|
|
|
|
2024-01-16 15:21:35 +00:00
|
|
|
subsonicClient = client.NewClient(config.URL())
|
2024-12-18 15:29:16 +00:00
|
|
|
|
2024-01-16 15:21:35 +00:00
|
|
|
err = subsonicClient.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(subsonicClient)
|
|
|
|
defer playbackCtl.Close()
|
|
|
|
|
|
|
|
tui := tui.NewPlayer(subsonicClient, playbackCtl)
|
|
|
|
if err := tui.Run(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|