1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
package main
import (
"context"
"fmt"
"github.com/delthas/go-libnp"
"log"
"time"
)
func main() {
info, err := libnp.GetInfo(context.Background())
if err != nil {
log.Fatal(err)
}
for _, v := range info.AlbumArtists {
fmt.Printf("Album Artist: %s\n", v)
}
for _, v := range info.Artists {
fmt.Printf("Artist: %s\n", v)
}
for _, v := range info.Composers {
fmt.Printf("Composer: %s\n", v)
}
for _, v := range info.Genres {
fmt.Printf("Genre: %s\n", v)
}
for _, v := range info.Lyricists {
fmt.Printf("Lyricist: %s\n", v)
}
if !info.Created.IsZero() {
fmt.Printf("Created: %s\n", info.Created.Format(time.RFC3339))
}
if !info.FirstPlayed.IsZero() {
fmt.Printf("First Played: %s\n", info.FirstPlayed.Format(time.RFC3339))
}
if !info.LastPlayed.IsZero() {
fmt.Printf("Last Played: %s\n", info.LastPlayed.Format(time.RFC3339))
}
if info.Album != "" {
fmt.Printf("Album Title: %s\n", info.Album)
}
if info.AlbumTrackCount != 0 {
fmt.Printf("Album Track Count: %d\n", info.AlbumTrackCount)
}
if info.ArtURL != "" {
fmt.Printf("Art URL: %s\n", info.ArtURL)
}
if info.BPM != 0 {
fmt.Printf("BPM: %d\n", info.BPM)
}
if info.DiscNumber != 0 {
fmt.Printf("Disc Number: %d\n", info.DiscNumber)
}
if info.Length != 0 {
fmt.Printf("Length: %d\n", info.Length/time.Second)
}
if info.PlayCount != 0 {
fmt.Printf("Play Count: %d\n", info.PlayCount)
}
if info.Subtitle != "" {
fmt.Printf("Subtitle: %s\n", info.Subtitle)
}
if info.Title != "" {
fmt.Printf("Title: %s\n", info.Title)
}
if info.TrackNumber != 0 {
fmt.Printf("Track Number: %d\n", info.TrackNumber)
}
if info.URL != "" {
fmt.Printf("URL: %s\n", info.URL)
}
if info.PlaybackType != libnp.PlaybackTypeUnknown {
fmt.Printf("Type: %v\n", info.PlaybackType)
}
}
|