From 2ed5c3d0e7f61534f7a01b8b200aff9115ddb444 Mon Sep 17 00:00:00 2001 From: softworkz Date: Tue, 29 Dec 2015 03:22:31 +0100 Subject: [PATCH] Fixed missing episode and season numbers when searching for episodes by date --- .../TV/TvdbEpisodeProvider.cs | 70 +++++++++++++++---- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs index 9c047f45d..6b902ed8a 100644 --- a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs @@ -486,24 +486,66 @@ namespace MediaBrowser.Providers.TV break; } - case "DVD_season": - { - var val = reader.ReadElementContentAsString(); + case "DVD_season": + { + var val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) - { - float num; + if (!string.IsNullOrWhiteSpace(val)) + { + float num; - if (float.TryParse(val, NumberStyles.Any, _usCulture, out num)) - { - item.DvdSeasonNumber = Convert.ToInt32(num); - } - } + if (float.TryParse(val, NumberStyles.Any, _usCulture, out num)) + { + item.DvdSeasonNumber = Convert.ToInt32(num); + } + } - break; - } + break; + } - case "absolute_number": + case "EpisodeNumber": + { + if (!item.IndexNumber.HasValue) + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + int rval; + + // int.TryParse is local aware, so it can be probamatic, force us culture + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + { + item.IndexNumber = rval; + } + } + } + + break; + } + + case "SeasonNumber": + { + if (!item.ParentIndexNumber.HasValue) + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + int rval; + + // int.TryParse is local aware, so it can be probamatic, force us culture + if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) + { + item.ParentIndexNumber = rval; + } + } + } + + break; + } + + case "absolute_number": { var val = reader.ReadElementContentAsString();