mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Subsonic: Support for some OpenSubsonic tags
Mainly this makes the MusicBrainz recording ID available
This commit is contained in:
parent
bed60c7cdf
commit
910056b0a6
3 changed files with 58 additions and 9 deletions
|
@ -21,7 +21,8 @@ import (
|
|||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/delucks/go-subsonic"
|
||||
"github.com/supersonic-app/go-subsonic/subsonic"
|
||||
"go.uploadedlobster.com/mbtypes"
|
||||
"go.uploadedlobster.com/scotty/internal/config"
|
||||
"go.uploadedlobster.com/scotty/internal/i18n"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
|
@ -99,15 +100,19 @@ func (b *SubsonicApiBackend) filterSongs(songs []*subsonic.Child, oldestTimestam
|
|||
}
|
||||
|
||||
func SongAsLove(song subsonic.Child, username string) models.Love {
|
||||
recordingMBID := mbtypes.MBID(song.MusicBrainzID)
|
||||
love := models.Love{
|
||||
UserName: username,
|
||||
Created: song.Starred,
|
||||
UserName: username,
|
||||
Created: song.Starred,
|
||||
RecordingMBID: recordingMBID,
|
||||
Track: models.Track{
|
||||
TrackName: song.Title,
|
||||
ReleaseName: song.Album,
|
||||
ArtistNames: []string{song.Artist},
|
||||
TrackNumber: song.Track,
|
||||
DiscNumber: song.DiscNumber,
|
||||
TrackName: song.Title,
|
||||
ReleaseName: song.Album,
|
||||
ArtistNames: []string{song.Artist},
|
||||
TrackNumber: song.Track,
|
||||
DiscNumber: song.DiscNumber,
|
||||
RecordingMBID: recordingMBID,
|
||||
Tags: []string{},
|
||||
AdditionalInfo: map[string]any{
|
||||
"subsonic_id": song.ID,
|
||||
},
|
||||
|
@ -115,7 +120,13 @@ func SongAsLove(song subsonic.Child, username string) models.Love {
|
|||
},
|
||||
}
|
||||
|
||||
if song.Genre != "" {
|
||||
if len(song.Genres) > 0 {
|
||||
genres := make([]string, 0, len(song.Genres))
|
||||
for _, genre := range song.Genres {
|
||||
genres = append(genres, genre.Name)
|
||||
}
|
||||
love.Track.Tags = genres
|
||||
} else if song.Genre != "" {
|
||||
love.Track.Tags = []string{song.Genre}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue