show full OpenSubsonic date where available

This commit is contained in:
Drew Weymouth
2024-12-23 17:23:26 -08:00
parent 37f678e5f3
commit ff3b1addf8
8 changed files with 108 additions and 20 deletions
@@ -458,7 +458,7 @@ func fillAlbum(a *jellyfin.Album, album *mediaprovider.Album) {
album.Duration = int(a.RunTimeTicks / runTimeTicksPerSecond)
album.ArtistIDs = artistIDs
album.ArtistNames = artistNames
album.Year = a.Year
album.Date.Year = &a.Year
album.TrackCount = a.ChildCount
album.Genres = a.Genres
album.Favorite = a.UserData.IsFavorite
+1 -1
View File
@@ -106,7 +106,7 @@ func (f albumFilter) Matches(album *Album) bool {
if f.options.ExcludeUnfavorited && !album.Favorite {
return false
}
if y := album.Year; y < f.options.MinYear || (f.options.MaxYear > 0 && y > f.options.MaxYear) {
if y := album.YearOrZero(); y < f.options.MinYear || (f.options.MaxYear > 0 && y > f.options.MaxYear) {
return false
}
if len(f.options.Genres) == 0 {
+15 -2
View File
@@ -32,6 +32,12 @@ const (
ReleaseTypeSpokenWord ReleaseType = 0x8000
)
type ItemDate struct {
Year *int
Month *int
Day *int
}
type Album struct {
ID string
CoverArtID string
@@ -39,14 +45,21 @@ type Album struct {
Duration int
ArtistIDs []string
ArtistNames []string
Year int
ReissueYear int
Date ItemDate
ReissueDate ItemDate
Genres []string
TrackCount int
Favorite bool
ReleaseTypes ReleaseTypes
}
func (a *Album) YearOrZero() int {
if a.Date.Year != nil {
return *a.Date.Year
}
return 0
}
type AlbumWithTracks struct {
Album
Tracks []*Track
@@ -581,14 +581,21 @@ func fillAlbum(subAlbum *subsonic.AlbumID3, album *mediaprovider.Album) {
genres = append(genres, subAlbum.Genre)
}
album.Year = subAlbum.Year
if subAlbum.OriginalReleaseDate != nil &&
subAlbum.OriginalReleaseDate.Year != nil &&
*subAlbum.OriginalReleaseDate.Year < subAlbum.Year {
album.Year = *subAlbum.OriginalReleaseDate.Year
if ord := subAlbum.OriginalReleaseDate; ord != nil && ord.Year != nil {
album.Date = mediaprovider.ItemDate{
Year: ord.Year,
Month: ord.Month,
Day: ord.Date,
}
} else {
album.Date.Year = &subAlbum.Year
}
if subAlbum.ReleaseDate != nil && subAlbum.ReleaseDate.Year != nil {
album.ReissueYear = *subAlbum.ReleaseDate.Year
if rd := subAlbum.ReleaseDate; rd != nil && rd.Year != nil {
album.ReissueDate = mediaprovider.ItemDate{
Year: rd.Year,
Month: rd.Month,
Day: rd.Date,
}
}
album.ID = subAlbum.ID