add more omitempty changes

This commit is contained in:
sentriz
2020-02-21 17:55:30 +00:00
parent 9b8a35df00
commit 7c170a68c2
4 changed files with 112 additions and 102 deletions

View File

@@ -52,6 +52,16 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
if album.TagArtist != nil {
ret.ArtistID = album.TagArtist.ID
}
// replace tags that we're present
if ret.Title == "" {
ret.Title = "<title>"
}
if ret.Artist == "" {
ret.Artist = "<artist>"
}
if ret.Album == "" {
ret.Album = "<album>"
}
return ret
}

View File

@@ -134,12 +134,12 @@ type TrackChild struct {
}
type Artists struct {
List []*Index `xml:"index,omitempty" json:"index"`
List []*Index `xml:"index" json:"index"`
}
type Artist struct {
ID int `xml:"id,attr,omitempty" json:"id,string"`
Name string `xml:"name,attr,omitempty" json:"name"`
Name string `xml:"name,attr" json:"name"`
CoverID int `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty,string"`
AlbumCount int `xml:"albumCount,attr" json:"albumCount"`
Albums []*Album `xml:"album,omitempty" json:"album,omitempty"`
@@ -147,12 +147,12 @@ type Artist struct {
type Indexes struct {
LastModified int `xml:"lastModified,attr,omitempty" json:"lastModified"`
Index []*Index `xml:"index,omitempty" json:"index"`
Index []*Index `xml:"index" json:"index"`
}
type Index struct {
Name string `xml:"name,attr,omitempty" json:"name"`
Artists []*Artist `xml:"artist,omitempty" json:"artist"`
Artists []*Artist `xml:"artist" json:"artist"`
}
type Directory struct {
@@ -164,7 +164,7 @@ type Directory struct {
}
type MusicFolders struct {
List []*MusicFolder `xml:"musicFolder,omitempty" json:"musicFolder,omitempty"`
List []*MusicFolder `xml:"musicFolder" json:"musicFolder"`
}
type MusicFolder struct {
@@ -224,7 +224,7 @@ type Playlist struct {
Created time.Time `xml:"created,attr" json:"created"`
Duration string `xml:"duration,attr" json:"duration,omitempty"`
Public bool `xml:"public,attr" json:"public,omitempty"`
List []*TrackChild `xml:"entry" json:"entry,omitempty"`
List []*TrackChild `xml:"entry" json:"entry"`
}
type SimilarArtist struct {

View File

@@ -6,28 +6,6 @@
"gonicVersion": "v0.7.0",
"albumList": {
"album": [
{
"id": "19",
"coverArt": "19",
"artist": "Ten Years After",
"title": "(1967) Ten Years After",
"parent": "18",
"isDir": true,
"songCount": 15,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
{
"id": "8",
"coverArt": "8",
"artist": "13th Floor Lowervators",
"title": "(1967) Easter Nowhere",
"parent": "7",
"isDir": true,
"songCount": 10,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
{
"id": "9",
"coverArt": "9",
@@ -39,6 +17,17 @@
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
{
"id": "19",
"coverArt": "19",
"artist": "Ten Years After",
"title": "(1967) Ten Years After",
"parent": "18",
"isDir": true,
"songCount": 15,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
{
"id": "13",
"coverArt": "13",
@@ -51,23 +40,24 @@
"created": "0001-01-01T00:00:00Z"
},
{
"id": "3",
"coverArt": "3",
"artist": "Jah Wobble, The Edge, Holger Czukay",
"title": "(1983) Snake Charmer",
"parent": "2",
"id": "21",
"coverArt": "21",
"artist": "Captain Beefheart",
"title": "(1970) Lick My Decals Off, Bitch",
"parent": "20",
"isDir": true,
"songCount": 5,
"songCount": 15,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
{
"id": "6",
"artist": "A Certain Ratio",
"title": "(1981) To EachOTHER.",
"parent": "4",
"id": "17",
"coverArt": "17",
"artist": "Swell Maps",
"title": "(1979) A Trip to Marineville",
"parent": "15",
"isDir": true,
"songCount": 9,
"songCount": 18,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
@@ -83,13 +73,12 @@
"created": "0001-01-01T00:00:00Z"
},
{
"id": "21",
"coverArt": "21",
"artist": "Captain Beefheart",
"title": "(1970) Lick My Decals Off, Bitch",
"parent": "20",
"id": "6",
"artist": "A Certain Ratio",
"title": "(1981) To EachOTHER.",
"parent": "4",
"isDir": true,
"songCount": 15,
"songCount": 9,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
@@ -105,13 +94,24 @@
"created": "0001-01-01T00:00:00Z"
},
{
"id": "17",
"coverArt": "17",
"artist": "Swell Maps",
"title": "(1979) A Trip to Marineville",
"parent": "15",
"id": "8",
"coverArt": "8",
"artist": "13th Floor Lowervators",
"title": "(1967) Easter Nowhere",
"parent": "7",
"isDir": true,
"songCount": 18,
"songCount": 10,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
},
{
"id": "3",
"coverArt": "3",
"artist": "Jah Wobble, The Edge, Holger Czukay",
"title": "(1983) Snake Charmer",
"parent": "2",
"isDir": true,
"songCount": 5,
"duration": 0,
"created": "0001-01-01T00:00:00Z"
}

View File

@@ -7,45 +7,14 @@
"albumList2": {
"album": [
{
"id": "13",
"coverArt": "13",
"artistId": "4",
"artist": "Anikas",
"name": "Anika",
"id": "6",
"artistId": "2",
"artist": "A Certain Ratio",
"name": "To Each...",
"songCount": 9,
"duration": 0,
"created": "2019-05-23T15:12:02.921473302+01:00"
},
{
"id": "19",
"coverArt": "19",
"artistId": "6",
"artist": "Ten Years After",
"name": "Ten Years After",
"songCount": 15,
"duration": 0,
"created": "2019-04-30T16:48:30+01:00"
},
{
"id": "5",
"coverArt": "5",
"artistId": "2",
"artist": "A Certain Ratio",
"name": "The Graveyard and the Ballroom",
"songCount": 14,
"duration": 0,
"created": "2019-06-05T17:46:37.675917974+01:00"
},
{
"id": "17",
"coverArt": "17",
"artistId": "5",
"artist": "Swell Maps",
"name": "A Trip to Marineville",
"songCount": 18,
"duration": 0,
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "3",
"coverArt": "3",
@@ -56,6 +25,26 @@
"duration": 0,
"created": "2019-05-16T22:10:52+01:00"
},
{
"id": "17",
"coverArt": "17",
"artistId": "5",
"artist": "Swell Maps",
"name": "A Trip to Marineville",
"songCount": 18,
"duration": 0,
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "5",
"coverArt": "5",
"artistId": "2",
"artist": "A Certain Ratio",
"name": "The Graveyard and the Ballroom",
"songCount": 14,
"duration": 0,
"created": "2019-06-05T17:46:37.675917974+01:00"
},
{
"id": "21",
"coverArt": "21",
@@ -66,6 +55,16 @@
"duration": 0,
"created": "2019-06-10T19:26:30.944742894+01:00"
},
{
"id": "13",
"coverArt": "13",
"artistId": "4",
"artist": "Anikas",
"name": "Anika",
"songCount": 9,
"duration": 0,
"created": "2019-05-23T15:12:02.921473302+01:00"
},
{
"id": "9",
"coverArt": "9",
@@ -77,23 +76,14 @@
"created": "2019-06-13T12:57:24.306717554+01:00"
},
{
"id": "16",
"coverArt": "16",
"artistId": "5",
"artist": "Swell Maps",
"name": "Jane From Occupied Europe",
"songCount": 16,
"id": "19",
"coverArt": "19",
"artistId": "6",
"artist": "Ten Years After",
"name": "Ten Years After",
"songCount": 15,
"duration": 0,
"created": "2019-04-30T16:48:48+01:00"
},
{
"id": "6",
"artistId": "2",
"artist": "A Certain Ratio",
"name": "To Each...",
"songCount": 9,
"duration": 0,
"created": "2019-05-23T15:12:02.921473302+01:00"
"created": "2019-04-30T16:48:30+01:00"
},
{
"id": "8",
@@ -104,6 +94,16 @@
"songCount": 10,
"duration": 0,
"created": "2019-06-13T12:57:28.850090338+01:00"
},
{
"id": "16",
"coverArt": "16",
"artistId": "5",
"artist": "Swell Maps",
"name": "Jane From Occupied Europe",
"songCount": 16,
"duration": 0,
"created": "2019-04-30T16:48:48+01:00"
}
]
}