package main

import (
	"fmt"
	"log"
	"whspbrd/pkg/mpris"
)

func main() {
	players, err := mpris.Mpris()
	if err != nil {
		log.Fatalf("Error: %v", err)
	}

	for _, p := range players {
		fmt.Printf("Player: %s\n", p.Name)
		fmt.Printf("Title : %s\n", p.Title)
		if len(p.Artist) > 0 {
			fmt.Printf("Artist: %s\n", p.Artist[0])
		}
		fmt.Printf("Album : %s\n", p.Album)

		if p.ArtURL != "" {
			if mpris.IsRemoteArt(p.ArtURL) {
				fmt.Printf("Remote artwork found: %s\n", p.ArtURL)
				err := mpris.DownloadArt(p.ArtURL, p.Name+"_art.jpg")
				if err != nil {
					fmt.Printf("Error downloading art: %v\n", err)
				} else {
					fmt.Printf("Artwork saved as %s_art.jpg\n", p.Name)
				}
			} else {
				fmt.Printf("Local artwork: %s\n", p.ArtURL)
			}
		} else {
			fmt.Println("Artwork: not available")
		}
		fmt.Println()
	}
}
