Adds Lyrics Support to Subsonic API (#1379)

* Add function 'isSynced' that identifies if lyrics are synced or not and add tests for the same

* implement 'getLyrics' which returns lyrics if they exist

Signed-off-by: Dheeraj Lalwani <lalwanidheeraj1234@gmail.com>

* remove timestamps frorom the the lyrics if they are synced, fix filters & clean up code

Signed-off-by: Dheeraj Lalwani <lalwanidheeraj1234@gmail.com>

* add snapshot tests for the 'Lyrics' response & add some clean up

Signed-off-by: Dheeraj Lalwani <lalwanidheeraj1234@gmail.com>

* add tests for 'GetLyrics' function

Signed-off-by: Dheeraj Lalwani <lalwanidheeraj1234@gmail.com>

* update the snapshot test & the test for 'GetLyrics' function

Signed-off-by: Dheeraj Lalwani <lalwanidheeraj1234@gmail.com>
This commit is contained in:
Dheeraj Lalwani
2021-10-20 02:03:06 +05:30
committed by GitHub
parent 3214783ce9
commit 5621551dd0
10 changed files with 169 additions and 2 deletions
@@ -0,0 +1 @@
{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","lyrics":{"artist":"Rick Astley","title":"Never Gonna Give You Up","value":"Never gonna give you up\n\t\t\t\tNever gonna let you down\n\t\t\t\tNever gonna run around and desert you\n\t\t\t\tNever gonna say goodbye"}}
@@ -0,0 +1 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><lyrics artist="Rick Astley" title="Never Gonna Give You Up">Never gonna give you up&#xA;&#x9;&#x9;&#x9;&#x9;Never gonna let you down&#xA;&#x9;&#x9;&#x9;&#x9;Never gonna run around and desert you&#xA;&#x9;&#x9;&#x9;&#x9;Never gonna say goodbye</lyrics></subsonic-response>
@@ -0,0 +1 @@
{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","lyrics":{"value":""}}
@@ -0,0 +1 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><lyrics></lyrics></subsonic-response>
+7
View File
@@ -46,6 +46,7 @@ type Subsonic struct {
PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"`
Bookmarks *Bookmarks `xml:"bookmarks,omitempty" json:"bookmarks,omitempty"`
ScanStatus *ScanStatus `xml:"scanStatus,omitempty" json:"scanStatus,omitempty"`
Lyrics *Lyrics `xml:"lyrics,omitempty" json:"lyrics,omitempty"`
}
type JsonWrapper struct {
@@ -346,3 +347,9 @@ type ScanStatus struct {
FolderCount int64 `xml:"folderCount,attr" json:"folderCount"`
LastScan *time.Time `xml:"lastScan,attr,omitempty" json:"lastScan,omitempty"`
}
type Lyrics struct {
Artist string `xml:"artist,omitempty,attr" json:"artist,omitempty"`
Title string `xml:"title,omitempty,attr" json:"title,omitempty"`
Value string `xml:",chardata" json:"value"`
}
@@ -561,4 +561,37 @@ var _ = Describe("Responses", func() {
})
})
})
Describe("Lyrics", func() {
BeforeEach(func() {
response.Lyrics = &Lyrics{}
})
Context("without data", func() {
It("should match .XML", func() {
Expect(xml.Marshal(response)).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.Marshal(response)).To(MatchSnapshot())
})
})
Context("with data", func() {
BeforeEach(func() {
response.Lyrics.Artist = "Rick Astley"
response.Lyrics.Title = "Never Gonna Give You Up"
response.Lyrics.Value = `Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna say goodbye`
})
It("should match .XML", func() {
Expect(xml.Marshal(response)).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.Marshal(response)).To(MatchSnapshot())
})
})
})
})