Skip to content

🎧 Your Personal Streaming Service

feat(plugins): add LibraryID to TrackInfo

Deluanfd930eefd73d
diff --git a/plugins/capabilities/scrobbler.go b/plugins/capabilities/scrobbler.go
index 34cf60015..ed8a4fb6c 100644
--- a/plugins/capabilities/scrobbler.go
+++ b/plugins/capabilities/scrobbler.go
@@ -68,6 +68,9 @@ type TrackInfo struct {
MBZReleaseGroupID string `json:"mbzReleaseGroupId,omitempty"`
// MBZReleaseTrackID is the MusicBrainz release track ID.
MBZReleaseTrackID string `json:"mbzReleaseTrackId,omitempty"`
+ // LibraryID is the ID of the library the track belongs to.
+ // Only included if the plugin has library permission with filesystem access for the track's library.
+ LibraryID int32 `json:"libraryId,omitempty"`
// Path is the full path to the track file, relative to the library root.
// Only included if the plugin has library permission with filesystem access for the track's library.
Path string `json:"path,omitempty"`
diff --git a/plugins/scrobbler_adapter.go b/plugins/scrobbler_adapter.go
index 4f7cd4661..02c2b2889 100644
--- a/plugins/scrobbler_adapter.go
+++ b/plugins/scrobbler_adapter.go
@@ -130,6 +130,7 @@ func mediaFileToTrackInfo(p *plugin, mf *model.MediaFile) capabilities.TrackInfo
MBZReleaseTrackID: mf.MbzReleaseTrackID,
}
if p.hasLibraryFilesystemAccess(mf.LibraryID) {
+ ti.LibraryID = int32(mf.LibraryID)
ti.Path = mf.Path
}
return ti
diff --git a/plugins/scrobbler_adapter_test.go b/plugins/scrobbler_adapter_test.go
index 0ee229022..c56d8a900 100644
--- a/plugins/scrobbler_adapter_test.go
+++ b/plugins/scrobbler_adapter_test.go
@@ -259,19 +259,25 @@ var _ = Describe("ScrobblerPlugin", Ordered, func() {
},
}
- It("includes Path when the plugin has filesystem access to the track's library", func() {
+ It("includes LibraryID and Path when the plugin has filesystem access to the track's library", func() {
p := &plugin{manifest: fsManifest, libraries: newLibraryAccess([]int{1}, false)}
- Expect(mediaFileToTrackInfo(p, track).Path).To(Equal("/music/test.flac"))
+ ti := mediaFileToTrackInfo(p, track)
+ Expect(ti.LibraryID).To(Equal(int32(1)))
+ Expect(ti.Path).To(Equal("/music/test.flac"))
})
- It("omits Path when the plugin lacks filesystem permission", func() {
+ It("omits LibraryID and Path when the plugin lacks filesystem permission", func() {
p := &plugin{manifest: &Manifest{}, libraries: newLibraryAccess([]int{1}, false)}
- Expect(mediaFileToTrackInfo(p, track).Path).To(BeEmpty())
+ ti := mediaFileToTrackInfo(p, track)
+ Expect(ti.LibraryID).To(BeZero())
+ Expect(ti.Path).To(BeEmpty())
})
- It("omits Path when the track's library is not in the allowed set", func() {
+ It("omits LibraryID and Path when the track's library is not in the allowed set", func() {
p := &plugin{manifest: fsManifest, libraries: newLibraryAccess([]int{2}, false)}
- Expect(mediaFileToTrackInfo(p, track).Path).To(BeEmpty())
+ ti := mediaFileToTrackInfo(p, track)
+ Expect(ti.LibraryID).To(BeZero())
+ Expect(ti.Path).To(BeEmpty())
})
})
})