feat(subsonic): add support for lyrics (#519)

* Add songLyrics extension since the getLyricsBySongId method is implemented

* Add support for lyrics

* Add check for getLyrics function

* fix typo

* chore: fix tests

* fix(lyrics): if lrc is formatted with empty spaces remove them

* fix(lint): use NewError correctly

bump ts
This commit is contained in:
./daniele
2025-08-26 11:09:00 +01:00
committed by sentriz
parent 5916a7fe7b
commit db97bc753e
11 changed files with 183 additions and 2 deletions

No files matched your search

+19
View File
@@ -71,6 +71,7 @@ type Response struct {
SimilarSongsTwo *SimilarSongsTwo `xml:"similarSongs2" json:"similarSongs2,omitempty"`
InternetRadioStations *InternetRadioStations `xml:"internetRadioStations" json:"internetRadioStations,omitempty"`
Lyrics *Lyrics `xml:"lyrics" json:"lyrics,omitempty"`
LyricsList *LyricsList `xml:"lyricsList" json:"lyricsList,omitempty"`
}
func NewResponse() *Response {
@@ -475,6 +476,24 @@ type Lyrics struct {
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
}
type Lyric struct {
Start int64 `xml:"start,attr" json:"start"`
Value string `xml:",chardata" json:"value"`
}
type LyricsList struct {
StructuredLyrics []StructuredLyrics `xml:"structuredLyrics" json:"structuredLyrics"`
}
type StructuredLyrics struct {
Lang string `xml:"lang,attr" json:"lang"` // ISO 639 (or und, xxx if unknown)
Synced bool `xml:"synced,attr" json:"synced"`
Lines []Lyric `xml:"line" json:"line"`
DisplayArtist string `xml:"displayArtist,attr,omitempty" json:"displayArtist,omitempty"`
DisplayTitle string `xml:"displayTitle,attr,omitempty" json:"displayTitle,omitempty"`
Offset int `xml:"offset,attr,omitempty" json:"offset,omitempty"`
}
type OpenSubsonicExtension struct {
Name string `xml:"name,attr" json:"name"`
Versions []int `xml:"versions" json:"versions"`