-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjalbum.go
40 lines (36 loc) · 1.44 KB
/
objalbum.go
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
package main
import (
"encoding/json"
)
// ObjectAlbum holds metadata about an album
type ObjectAlbum struct {
Discs []*ObjectDisc `json:"discs,omitempty"` //The discs in this album
Copyrights []string `json:"copyrights,omitempty"` //The copyrights that apply to this album
Label string `json:"label,omitempty"` //The record label or studio that released this album
Provider string `json:"provider,omitempty"`
URI string `json:"uri,omitempty"` //The URI that refers to this album object
Name string `json:"name,omitempty"` //The name of this album
Description string `json:"description,omitempty"` //The description of this album
Artworks []*ObjectArtwork `json:"artworks,omitempty"` //The artworks for this album
DateTime string `json:"datetime,omitempty"` //The release date of this album
Creators []*Object `json:"creators,omitempty"` //The creators of this album
Explicit bool `json:"explicit,omitempty"` //Whether or not this album contains explicit tracks
}
func (obj *ObjectAlbum) JSON() []byte {
objJSON, err := json.Marshal(obj)
if err != nil {
return nil
}
return objJSON
}
func (obj *ObjectAlbum) IsEmpty() bool {
if len(obj.Discs) == 0 {
return true
}
for i := 0; i < len(obj.Discs); i++ {
if len(obj.Discs[i].Streams) > 0 {
return false
}
}
return true
}