mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-31 07:27:58 +01:00
* fix(jellyfin): match Jellyfin's item payloads so strict clients can sync Manet (iOS/macOS) aborted its whole library sync on the first item that was missing a key its decoder requires, leaving the library empty (#6147). Every gap was a field real Jellyfin always sends: - dates now use .NET's round-trip layout with 7 fractional digits, which Manet requires and plain RFC3339 failed - playlists carry SortName/DateCreated, and every item carries MediaType, ImageTags, ChannelId and, when Fields asks, Genres/GenreItems/Tags - albums carry Artists and LocationType; songs always carry HasLyrics - the library view is a full CollectionFolder (ChildCount, DateCreated, SortName, Path, LocationType, UserData), read from the library rows rather than the user projection, which has no counts - IncludeItemTypes matches case-insensitively and returns nothing for Jellyfin kinds Navidrome has none of, instead of falling back to every album Verified against a real Jellyfin 10.10.7 server and a live Manet client. * refactor(jellyfin): fold the repeated empty-list defaults into one helper The three mappers each initialised Genres/GenreItems/Tags the same way, and the e2e suite grew three near-identical specs walking every item type. Both now go through a single helper and one table. * refactor(jellyfin): fill the always-present item fields at the serialization edge The defaults real Jellyfin puts on every item were spread across three mappers, so item types nobody had tested yet (playlists, genres, the library view) still shipped payloads a strict client rejects. stampItem now takes the request's Fields and fills them for every item, which is provably the only path to JSON. Also drops the hand-copied BaseItemKind list: only an absent IncludeItemTypes defaults to albums now, so any type Navidrome does not serve returns nothing, as it would from Jellyfin. The synthetic playlists folder matches case-insensitively like the rest, /Items/{libraryId} reads the full library row instead of the count-less user projection, and PremiereDate and LastPlayedDate go through jellyfinDate rather than spelling the layout out again.
71 lines
2.2 KiB
Go
71 lines
2.2 KiB
Go
package e2e
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/navidrome/navidrome/server/jellyfin/dto"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Lyrics", func() {
|
|
BeforeEach(func() { setupTestDB() })
|
|
|
|
Describe("PlaybackInfo", func() {
|
|
It("advertises a Lyric stream for a track with embedded lyrics", func() {
|
|
id := songID("Stairway To Heaven")
|
|
var info dto.PlaybackInfoResponse
|
|
parseInto(get("/Items/"+enc(id)+"/PlaybackInfo"), &info)
|
|
var found bool
|
|
for _, s := range info.MediaSources[0].MediaStreams {
|
|
if s.Type == "Lyric" {
|
|
found = true
|
|
}
|
|
}
|
|
Expect(found).To(BeTrue())
|
|
})
|
|
|
|
It("does not advertise a Lyric stream for a track without lyrics", func() {
|
|
id := songID("So What")
|
|
var info dto.PlaybackInfoResponse
|
|
parseInto(get("/Items/"+enc(id)+"/PlaybackInfo"), &info)
|
|
for _, s := range info.MediaSources[0].MediaStreams {
|
|
Expect(s.Type).ToNot(Equal("Lyric"))
|
|
}
|
|
})
|
|
})
|
|
|
|
Describe("GET /Audio/{id}/Lyrics", func() {
|
|
It("returns the LyricDto for a track with embedded synced lyrics", func() {
|
|
id := songID("Stairway To Heaven")
|
|
var lyrics dto.LyricDto
|
|
parseInto(get("/Audio/"+enc(id)+"/Lyrics"), &lyrics)
|
|
Expect(lyrics.Lyrics).To(HaveLen(2))
|
|
Expect(lyrics.Lyrics[0].Text).To(Equal("There's a lady who's sure"))
|
|
Expect(lyrics.Lyrics[0].Start).ToNot(BeNil())
|
|
Expect(*lyrics.Lyrics[0].Start).To(Equal(int64(10000000)))
|
|
Expect(lyrics.Metadata.IsSynced).To(BeTrue())
|
|
})
|
|
|
|
It("returns 404 for a track without lyrics", func() {
|
|
id := songID("So What")
|
|
Expect(get("/Audio/" + enc(id) + "/Lyrics").Code).To(Equal(http.StatusNotFound))
|
|
})
|
|
|
|
It("returns 404 for a fabricated id", func() {
|
|
Expect(get("/Audio/" + enc(testID("nope")) + "/Lyrics").Code).To(Equal(http.StatusNotFound))
|
|
})
|
|
})
|
|
|
|
Describe("HasLyrics badge", func() {
|
|
It("is true for a track with embedded lyrics and false otherwise", func() {
|
|
var stairway dto.BaseItemDto
|
|
parseInto(get("/Items/"+enc(songID("Stairway To Heaven"))), &stairway)
|
|
Expect(*stairway.HasLyrics).To(BeTrue())
|
|
|
|
var soWhat dto.BaseItemDto
|
|
parseInto(get("/Items/"+enc(songID("So What"))), &soWhat)
|
|
Expect(*soWhat.HasLyrics).To(BeFalse())
|
|
})
|
|
})
|
|
})
|