118 lines
3.7 KiB
Go
118 lines
3.7 KiB
Go
package main
|
|
|
|
// Bubbles, bubbletea, lipgloss needed
|
|
|
|
func main() {
|
|
/*
|
|
Check mpv because i think it sends urls to it from the backend and mpv gets the song and handles the song part
|
|
Also the ui should be cached to a local db file without hosting something like redis to get the entire song list by artist -> ablum -> song
|
|
The ui will format the file properly to be a column style where the songs in an album are listed under in a grid.
|
|
|
|
--------------------
|
|
Optimized Horizontal Concept
|
|
--------------------
|
|
|
|
+--------------------+----------------------+----------------------------+
|
|
| [1] Artists | [2] Albums | Now Playing |
|
|
| > Artist A | > Album 1 (2024) | Track Name |
|
|
| Artist B | Album 2 (2021) | Artist - Album |
|
|
| Artist C | | [=========>-----] 02:14 |
|
|
| Artist D |----------------------| FLAC 24-bit/96kHz |
|
|
| Artist E | [3] Songs +----------------------------+
|
|
| Artist F | > 01. Intro 01:45 | [4] Queue (Up Next) |
|
|
| Artist G | 02. Track A 03:22 | 01. Track A |
|
|
| Artist H | 03. Track B 04:10 | > 02. Track B (Playing) |
|
|
| Artist I | 04. Track C 02:58 | 03. Track C |
|
|
| Artist J | 05. Outro 05:12 | 04. Other Song |
|
|
+--------------------+----------------------+----------------------------+
|
|
| [>] Playing | Vol: 85% | [S]huffle: Off | [R]epeat: All | /: Search |
|
|
+------------------------------------------------------------------------+
|
|
|
|
-----------------------
|
|
Breaking into parts
|
|
-----------------------
|
|
block 4 and 5 in the ui update from the mpv and server constantly where 1, 2, 3 are static from db
|
|
|
|
1. Mpv for audio backend
|
|
2. sqlite for database to store all information from server locally once and can resync
|
|
3. tui
|
|
|
|
-----------------------
|
|
Endpoints
|
|
-----------------------
|
|
|
|
getPlaylists - lists all playlists
|
|
getPlaylist - lists all songs in specifc playlist
|
|
*/
|
|
// sock := "/tmp/mpv.sock"
|
|
// _, _ = godotenv.Load(), os.Remove(sock)
|
|
|
|
// ctx, cancel := context.WithCancel(context.Background())
|
|
// defer cancel()
|
|
|
|
// client := &NavidromeClient{
|
|
// BaseURL: os.Getenv("URL"),
|
|
// Username: os.Getenv("USERNAME"),
|
|
// Password: os.Getenv("PASSWORD"),
|
|
// APIVersion: os.Getenv("SUBSONIC_API_VERSION"),
|
|
// ClientName: os.Getenv("CLIENT_NAME"),
|
|
// HTTP: &http.Client{Timeout: 10 * time.Second},
|
|
// }
|
|
//
|
|
// db := &Database{
|
|
// LibraryPath: "db-library.json",
|
|
// LibraryDB: nil,
|
|
// }
|
|
|
|
// if err := db.loadDatabase(client); err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// fmt.Println(db.LibraryDB[0].Artist[0].Name)
|
|
// params := url.Values{}
|
|
// params.Set("id", "38CbfBE5cwLRQ5iHt3iAYN")
|
|
// stream, err := client.newURLRequest("stream", params)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// cmd := exec.CommandContext(ctx, "mpv",
|
|
// "--no-video",
|
|
// "--idle=yes",
|
|
// "--no-terminal",
|
|
// "--ytdl=no",
|
|
// "--input-ipc-server="+sock,
|
|
// )
|
|
// if err := cmd.Start(); err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// fmt.Println(stream)
|
|
|
|
// if err := db.requestDatabase(client); err != nil {
|
|
// panic(err)
|
|
// }
|
|
//
|
|
// file, err := os.Create(db.LibraryPath)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
//
|
|
// encoder := json.NewEncoder(file)
|
|
// encoder.SetIndent("", " ")
|
|
// encoder.Encode(db.LibraryDB)
|
|
|
|
// resp, err := client.HTTP.Get(outURL)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// defer resp.Body.Close()
|
|
//
|
|
// body, err := io.ReadAll(resp.Body)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// fmt.Println(string(body))
|
|
}
|