From b582127e145d27801796e05b18ac373b323e23e5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 8 Apr 2014 12:14:35 -0700 Subject: [PATCH] Fixed a couple xbmc metadata bugs --- .../MetaData/Consumers/Xbmc/XbmcMetadata.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/MetaData/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/MetaData/Consumers/Xbmc/XbmcMetadata.cs index 0e74e81c4..78a61588b 100644 --- a/src/NzbDrone.Core/MetaData/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/MetaData/Consumers/Xbmc/XbmcMetadata.cs @@ -193,16 +193,22 @@ public override MetadataFile FindMetadataFile(Series series, string path) { metadata.Type = MetadataType.SeasonImage; - var seasonNumber = seasonMatch.Groups["season"].Value; + var seasonNumberMatch = seasonMatch.Groups["season"].Value; + int seasonNumber; - if (seasonNumber.Contains("specials")) + if (seasonNumberMatch.Contains("specials")) { metadata.SeasonNumber = 0; } + else if (Int32.TryParse(seasonNumberMatch, out seasonNumber)) + { + metadata.SeasonNumber = seasonNumber; + } + else { - metadata.SeasonNumber = Convert.ToInt32(seasonNumber); + return null; } return metadata; @@ -462,7 +468,7 @@ private MetadataFile WriteEpisodeImages(Series series, EpisodeFile episodeFile, var filename = GetEpisodeImageFilename(episodeFile.Path); var relativePath = DiskProviderBase.GetRelativePath(series.Path, filename); - var existingMetadata = existingMetadataFiles.SingleOrDefault(c => c.Type == MetadataType.EpisodeImage && + var existingMetadata = existingMetadataFiles.FirstOrDefault(c => c.Type == MetadataType.EpisodeImage && c.EpisodeFileId == episodeFile.Id); if (existingMetadata != null)