From ad3e4dee0e8eaa21fbb0b24958a0dfdb6be7cc76 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 15 Nov 2013 10:10:56 -0500 Subject: [PATCH] fixes #627 - Populate album release date with id3 info, when availalbe --- .../Music/AlbumDynamicInfoProvider.cs | 18 ++++++++++++++++++ .../Music/AlbumInfoFromSongProvider.cs | 17 ----------------- MediaBrowser.Providers/Music/LastfmHelper.cs | 18 +++++++++++------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/MediaBrowser.Providers/Music/AlbumDynamicInfoProvider.cs b/MediaBrowser.Providers/Music/AlbumDynamicInfoProvider.cs index 085ff9b54..5c14a2f56 100644 --- a/MediaBrowser.Providers/Music/AlbumDynamicInfoProvider.cs +++ b/MediaBrowser.Providers/Music/AlbumDynamicInfoProvider.cs @@ -69,6 +69,24 @@ namespace MediaBrowser.Providers.Music .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); + var date = songs.Select(i => i.PremiereDate) + .FirstOrDefault(i => i.HasValue); + + if (date.HasValue) + { + album.PremiereDate = date.Value; + album.ProductionYear = date.Value.Year; + } + else + { + var year = songs.Select(i => i.ProductionYear ?? 1800).FirstOrDefault(i => i != 1800); + + if (year != 1800) + { + album.ProductionYear = year; + } + } + // Don't save to the db return FalseTaskResult; } diff --git a/MediaBrowser.Providers/Music/AlbumInfoFromSongProvider.cs b/MediaBrowser.Providers/Music/AlbumInfoFromSongProvider.cs index d74b9b038..9606279f7 100644 --- a/MediaBrowser.Providers/Music/AlbumInfoFromSongProvider.cs +++ b/MediaBrowser.Providers/Music/AlbumInfoFromSongProvider.cs @@ -107,23 +107,6 @@ namespace MediaBrowser.Providers.Music } } - var date = songs.Select(i => i.PremiereDate).FirstOrDefault(i => i.HasValue); - - if (date != null) - { - album.PremiereDate = date.Value; - album.ProductionYear = date.Value.Year; - } - else - { - var year = songs.Select(i => i.ProductionYear ?? 1800).FirstOrDefault(i => i != 1800); - - if (year != 1800) - { - album.ProductionYear = year; - } - } - if (!item.LockedFields.Contains(MetadataFields.Studios)) { album.Studios = songs.SelectMany(i => i.Studios) diff --git a/MediaBrowser.Providers/Music/LastfmHelper.cs b/MediaBrowser.Providers/Music/LastfmHelper.cs index 9d24875b2..800fdc438 100644 --- a/MediaBrowser.Providers/Music/LastfmHelper.cs +++ b/MediaBrowser.Providers/Music/LastfmHelper.cs @@ -103,15 +103,19 @@ namespace MediaBrowser.Providers.Music item.Overview = overview; } - DateTime release; - - if (DateTime.TryParse(data.releasedate, out release)) + // Only grab the date here if the album doesn't already have one, since id3 tags are preferred + if (!item.PremiereDate.HasValue) { - // Lastfm sends back null as sometimes 1901, other times 0 - if (release.Year > 1901) + DateTime release; + + if (DateTime.TryParse(data.releasedate, out release)) { - item.PremiereDate = release; - item.ProductionYear = release.Year; + // Lastfm sends back null as sometimes 1901, other times 0 + if (release.Year > 1901) + { + item.PremiereDate = release; + item.ProductionYear = release.Year; + } } }