Implement originalReleaseDate in OpenSubsonic responses. (#2733)
See https://github.com/opensubsonic/open-subsonic-api/pull/80
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"mime"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/navidrome/navidrome/consts"
|
||||
@@ -244,6 +245,24 @@ func childrenFromAlbums(ctx context.Context, als model.Albums) []responses.Child
|
||||
return children
|
||||
}
|
||||
|
||||
// toItemDate converts a string date in the formats 'YYYY-MM-DD', 'YYYY-MM' or 'YYYY' to an OS ItemDate
|
||||
func toItemDate(date string) responses.ItemDate {
|
||||
itemDate := responses.ItemDate{}
|
||||
if date == "" {
|
||||
return itemDate
|
||||
}
|
||||
parts := strings.Split(date, "-")
|
||||
if len(parts) > 2 {
|
||||
itemDate.Day, _ = strconv.Atoi(parts[2])
|
||||
}
|
||||
if len(parts) > 1 {
|
||||
itemDate.Month, _ = strconv.Atoi(parts[1])
|
||||
}
|
||||
itemDate.Year, _ = strconv.Atoi(parts[0])
|
||||
|
||||
return itemDate
|
||||
}
|
||||
|
||||
func buildItemGenres(genres model.Genres) []responses.ItemGenre {
|
||||
itemGenres := make([]responses.ItemGenre, len(genres))
|
||||
for i, g := range genres {
|
||||
@@ -301,5 +320,6 @@ func buildAlbumID3(ctx context.Context, album model.Album) responses.AlbumID3 {
|
||||
dir.MusicBrainzId = album.MbzAlbumID
|
||||
dir.IsCompilation = album.Compilation
|
||||
dir.SortName = album.SortAlbumName
|
||||
dir.OriginalReleaseDate = toItemDate(album.OriginalDate)
|
||||
return dir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user