diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go
index dd500c60c..ce88988d2 100644
--- a/server/subsonic/helpers.go
+++ b/server/subsonic/helpers.go
@@ -188,6 +188,8 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
child.BookmarkPosition = mf.BookmarkPosition
child.Comment = mf.Comment
child.Bpm = int32(mf.Bpm)
+ child.MediaType = responses.MediaTypeSong
+ child.MusicBrainzId = mf.MbzRecordingID
return child
}
@@ -236,6 +238,8 @@ func childFromAlbum(_ context.Context, al model.Album) responses.Child {
child.Played = &al.PlayDate
}
child.UserRating = int32(al.Rating)
+ child.MediaType = responses.MediaTypeAlbum
+ child.MusicBrainzId = al.MbzAlbumID
return child
}
diff --git a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON
index dbbf6396f..db626b5c5 100644
--- a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON
@@ -10,10 +10,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
]
}
diff --git a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML
index d17a9e812..a45332c19 100644
--- a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON
index 7ab8e7d5b..7934ea4a7 100644
--- a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON
@@ -8,8 +8,8 @@
"id": "1",
"name": "album",
"artist": "artist",
- "userRating": 0,
"genre": "rock",
+ "userRating": 0,
"genres": [
{
"name": "rock"
@@ -29,14 +29,6 @@
"track": 1,
"year": 1985,
"genre": "Rock",
- "genres": [
- {
- "name": "rock"
- },
- {
- "name": "progressive"
- }
- ],
"coverArt": "1",
"size": 8421341,
"contentType": "audio/flac",
@@ -47,8 +39,18 @@
"duration": 146,
"bitRate": 320,
"isVideo": false,
+ "mediaType": "song",
+ "musicBrainzId": "4321",
"bpm": 127,
- "comment": "a comment"
+ "comment": "a comment",
+ "genres": [
+ {
+ "name": "rock"
+ },
+ {
+ "name": "progressive"
+ }
+ ]
}
]
}
diff --git a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML
index 9ca452e7c..128dab3e5 100644
--- a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML
@@ -1,8 +1,8 @@
-
+
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON
index 9c8600177..c87488cbf 100644
--- a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON
@@ -11,10 +11,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
},
"position": 123,
"username": "user2",
diff --git a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML
index f753cdc82..cb2ac042f 100644
--- a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML
@@ -1,7 +1,7 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON
index 0c7330801..bab848ffd 100644
--- a/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON
@@ -15,14 +15,6 @@
"track": 1,
"year": 1985,
"genre": "Rock",
- "genres": [
- {
- "name": "rock"
- },
- {
- "name": "progressive"
- }
- ],
"coverArt": "1",
"size": 8421341,
"contentType": "audio/flac",
@@ -33,8 +25,18 @@
"duration": 146,
"bitRate": 320,
"isVideo": false,
+ "mediaType": "song",
+ "musicBrainzId": "4321",
"bpm": 127,
- "comment": "a comment"
+ "comment": "a comment",
+ "genres": [
+ {
+ "name": "rock"
+ },
+ {
+ "name": "progressive"
+ }
+ ]
}
],
"id": "1",
diff --git a/server/subsonic/responses/.snapshots/Responses Child with data should match .XML b/server/subsonic/responses/.snapshots/Responses Child with data should match .XML
index 22ab7893b..1ddcf490f 100644
--- a/server/subsonic/responses/.snapshots/Responses Child with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses Child with data should match .XML
@@ -1,6 +1,6 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON b/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON
index b239d6476..657eca88e 100644
--- a/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON
@@ -9,10 +9,12 @@
{
"id": "1",
"isDir": false,
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
],
"id": "",
diff --git a/server/subsonic/responses/.snapshots/Responses Child without data should match .XML b/server/subsonic/responses/.snapshots/Responses Child without data should match .XML
index 2b736b573..209894db4 100644
--- a/server/subsonic/responses/.snapshots/Responses Child without data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses Child without data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON
index 05c5efc0c..1496372ef 100644
--- a/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON
@@ -10,10 +10,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
],
"id": "1",
diff --git a/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML b/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML
index 2f1da276b..dd507bea1 100644
--- a/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON
index bbc33ddb0..2d5bb7a35 100644
--- a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON
@@ -10,10 +10,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
],
"current": "111",
diff --git a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML
index 5d7155d44..49cb2416c 100644
--- a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON
index 1547d7458..71caff2ae 100644
--- a/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON
@@ -14,11 +14,13 @@
"title": "title",
"album": "album",
"artist": "artist",
- "genres": [],
"duration": 120,
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
},
{
"id": "2",
@@ -26,11 +28,13 @@
"title": "title 2",
"album": "album",
"artist": "artist",
- "genres": [],
"duration": 300,
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
],
"id": "ABC123",
diff --git a/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML b/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML
index de0ba71da..c85d8c0ce 100644
--- a/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON
index 96c42074a..85b979687 100644
--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON
@@ -10,10 +10,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
]
}
diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML
index bfd6c31e0..a48b660dc 100644
--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON
index 45aaf997e..deaada7db 100644
--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON
@@ -10,10 +10,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
]
}
diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML
index 00da80758..003cf1d11 100644
--- a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON
index 4deb55314..b87123262 100644
--- a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON
@@ -10,10 +10,12 @@
"id": "1",
"isDir": false,
"title": "title",
- "genres": [],
"isVideo": false,
+ "mediaType": "",
+ "musicBrainzId": "",
"bpm": 0,
- "comment": ""
+ "comment": "",
+ "genres": []
}
]
}
diff --git a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML
index 1acf56f1b..88013f911 100644
--- a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML
+++ b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML
@@ -1,5 +1,5 @@
-
+
diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go
index 07c3b07f0..3e88d1ae2 100644
--- a/server/subsonic/responses/responses.go
+++ b/server/subsonic/responses/responses.go
@@ -106,6 +106,14 @@ type Indexes struct {
IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`
}
+type MediaType string
+
+const (
+ MediaTypeSong MediaType = "song"
+ MediaTypeAlbum MediaType = "album"
+ MediaTypeArtist MediaType = "artist"
+)
+
type Child struct {
Id string `xml:"id,attr" json:"id"`
Parent string `xml:"parent,attr,omitempty" json:"parent,omitempty"`
@@ -117,7 +125,6 @@ type Child struct {
Track int32 `xml:"track,attr,omitempty" json:"track,omitempty"`
Year int32 `xml:"year,attr,omitempty" json:"year,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
- Genres ItemGenres `xml:"genres" json:"genres"`
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
Size int64 `xml:"size,attr,omitempty" json:"size,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
@@ -129,7 +136,6 @@ type Child struct {
BitRate int32 `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
Path string `xml:"path,attr,omitempty" json:"path,omitempty"`
PlayCount int64 `xml:"playCount,attr,omitempty" json:"playCount,omitempty"`
- Played *time.Time `xml:"played,attr,omitempty" json:"played,omitempty"`
DiscNumber int32 `xml:"discNumber,attr,omitempty" json:"discNumber,omitempty"`
Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
AlbumId string `xml:"albumId,attr,omitempty" json:"albumId,omitempty"`
@@ -139,11 +145,16 @@ type Child struct {
SongCount int32 `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
IsVideo bool `xml:"isVideo,attr" json:"isVideo"`
BookmarkPosition int64 `xml:"bookmarkPosition,attr,omitempty" json:"bookmarkPosition,omitempty"`
- Bpm int32 `xml:"bpm,attr" json:"bpm"`
- Comment string `xml:"comment,attr" json:"comment"`
/*
*/
+ // OpenSubsonic extensions
+ Played *time.Time `xml:"played,attr,omitempty" json:"played,omitempty"`
+ MediaType MediaType `xml:"mediaType,attr" json:"mediaType"`
+ MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
+ Bpm int32 `xml:"bpm,attr" json:"bpm"`
+ Comment string `xml:"comment,attr" json:"comment"`
+ Genres ItemGenres `xml:"genres" json:"genres"`
}
type Songs struct {
@@ -188,22 +199,24 @@ type ArtistID3 struct {
}
type AlbumID3 struct {
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
- Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
- ArtistId string `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
- CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
- SongCount int32 `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
- Duration int32 `xml:"duration,attr,omitempty" json:"duration,omitempty"`
- PlayCount int64 `xml:"playCount,attr,omitempty" json:"playCount,omitempty"`
- Played *time.Time `xml:"played,attr,omitempty" json:"played,omitempty"`
- Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
- Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
- UserRating int32 `xml:"userRating,attr" json:"userRating"`
- Year int32 `xml:"year,attr,omitempty" json:"year,omitempty"`
- Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
- Genres ItemGenres `xml:"genres" json:"genres"`
- MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
+ Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
+ ArtistId string `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
+ CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
+ SongCount int32 `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
+ Duration int32 `xml:"duration,attr,omitempty" json:"duration,omitempty"`
+ PlayCount int64 `xml:"playCount,attr,omitempty" json:"playCount,omitempty"`
+ Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
+ Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
+ Year int32 `xml:"year,attr,omitempty" json:"year,omitempty"`
+ Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
+
+ // OpenSubsonic extensions
+ Played *time.Time `xml:"played,attr,omitempty" json:"played,omitempty"`
+ UserRating int32 `xml:"userRating,attr" json:"userRating"`
+ Genres ItemGenres `xml:"genres" json:"genres"`
+ MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"`
}
type ArtistWithAlbumsID3 struct {
diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go
index 14cc2d26c..08ff758f8 100644
--- a/server/subsonic/responses/responses_test.go
+++ b/server/subsonic/responses/responses_test.go
@@ -142,7 +142,7 @@ var _ = Describe("Responses", func() {
Year: 1985, Genre: "Rock", CoverArt: "1", Size: 8421341, ContentType: "audio/flac",
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
Duration: 146, BitRate: 320, Starred: &t, Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}},
- Comment: "a comment", Bpm: 127,
+ Comment: "a comment", Bpm: 127, MediaType: MediaTypeSong, MusicBrainzId: "4321",
}
response.Directory.Child = child
})
@@ -179,7 +179,7 @@ var _ = Describe("Responses", func() {
Year: 1985, Genre: "Rock", CoverArt: "1", Size: 8421341, ContentType: "audio/flac",
Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3",
Duration: 146, BitRate: 320, Starred: &t, Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}},
- Comment: "a comment", Bpm: 127,
+ Comment: "a comment", Bpm: 127, MediaType: MediaTypeSong, MusicBrainzId: "4321",
}}
response.AlbumWithSongsID3.AlbumID3 = album
response.AlbumWithSongsID3.Song = songs