From 1ea627a6e7ebbabf76327e323a4cf774d531051d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 25 Aug 2013 15:54:18 -0400 Subject: [PATCH] Fixed blank ForcedSortName --- MediaBrowser.Controller/Entities/BaseItem.cs | 7 ++++++- .../Providers/BaseItemXmlParser.cs | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 5440003910..a75dc47e1d 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -409,7 +409,12 @@ namespace MediaBrowser.Controller.Entities { get { - return ForcedSortName ?? _sortName ?? (_sortName = CreateSortName()); + if (!string.IsNullOrEmpty(ForcedSortName)) + { + return ForcedSortName; + } + + return _sortName ?? (_sortName = CreateSortName()); } } diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 5f5dcb4f2b..ba4f84ac23 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -173,8 +173,16 @@ namespace MediaBrowser.Controller.Providers break; } case "SortTitle": - item.ForcedSortName = reader.ReadElementContentAsString(); - break; + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + item.ForcedSortName = val; + } + + break; + } case "Overview": case "Description": @@ -503,7 +511,7 @@ namespace MediaBrowser.Controller.Providers { DateTime airDate; - if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850) + if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out airDate) && airDate.Year > 1850) { item.PremiereDate = airDate.ToUniversalTime(); item.ProductionYear = airDate.Year; @@ -522,7 +530,7 @@ namespace MediaBrowser.Controller.Providers { DateTime airDate; - if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850) + if (DateTime.TryParseExact(firstAired, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out airDate) && airDate.Year > 1850) { item.EndDate = airDate.ToUniversalTime(); }