diff --git a/MediaBrowser.Controller/Extensions/XmlExtensions.cs b/MediaBrowser.Controller/Extensions/XmlExtensions.cs
index 941d9fca7b..d28febe7c9 100644
--- a/MediaBrowser.Controller/Extensions/XmlExtensions.cs
+++ b/MediaBrowser.Controller/Extensions/XmlExtensions.cs
@@ -108,6 +108,38 @@ namespace MediaBrowser.Controller.Extensions
return defaultString;
}
+ ///
+ /// Safes the get DateTime.
+ ///
+ /// The doc.
+ /// The path.
+ /// System.DateTime.
+ public static DateTime? SafeGetDateTime(this XmlDocument doc, string path)
+ {
+ return SafeGetDateTime(doc, path, null);
+ }
+
+ ///
+ /// Safes the get DateTime.
+ ///
+ /// The doc.
+ /// The path.
+ /// The default date.
+ /// System.DateTime.
+ public static DateTime? SafeGetDateTime(this XmlDocument doc, string path, DateTime? defaultDate)
+ {
+ var rvalNode = doc.SelectSingleNode(path);
+
+ if (rvalNode != null)
+ {
+ var text = rvalNode.InnerText;
+ DateTime date;
+ if (DateTime.TryParse(text, out date))
+ return date;
+ }
+ return defaultDate;
+ }
+
///
/// Safes the get string.
///
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 19e6c17471..921e16eed9 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -64,6 +64,7 @@
+
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
index 3dbdea7bf6..d7b2c2a34a 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Configuration;
+using System.Xml.Linq;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
@@ -374,6 +375,14 @@ namespace MediaBrowser.Controller.Providers.TV
series.CommunityRating = doc.SafeGetSingle("//Rating", 0, 10);
series.AirDays = TVUtils.GetAirDays(doc.SafeGetString("//Airs_DayOfWeek"));
series.AirTime = doc.SafeGetString("//Airs_Time");
+ SeriesStatus seriesStatus;
+ if(Enum.TryParse(doc.SafeGetString("//Status"), out seriesStatus))
+ series.Status = seriesStatus;
+ series.PremiereDate = doc.SafeGetDateTime("//FirstAired");
+ if (series.PremiereDate.HasValue)
+ series.ProductionYear = series.PremiereDate.Value.Year;
+ //Runtime is in minutes, and 1 tick = 10000 ms
+ series.RunTimeTicks = doc.SafeGetInt32("//Runtime") * 6;
string s = doc.SafeGetString("//Network");
@@ -404,6 +413,27 @@ namespace MediaBrowser.Controller.Providers.TV
}
}
}
+
+ if (series.Status == SeriesStatus.Ended) {
+
+ var document = XDocument.Load(new XmlNodeReader(doc));
+ var dates = document.Descendants("Episode").Where(x => {
+ var seasonNumber = x.Element("SeasonNumber");
+ var firstAired = x.Element("FirstAired");
+ return firstAired != null && seasonNumber != null && (!string.IsNullOrEmpty(seasonNumber.Value) && seasonNumber.Value != "0") && !string.IsNullOrEmpty(firstAired.Value);
+ }).Select(x => {
+ DateTime? date = null;
+ DateTime tempDate;
+ var firstAired = x.Element("FirstAired");
+ if (firstAired != null && DateTime.TryParse(firstAired.Value, out tempDate))
+ {
+ date = tempDate;
+ }
+ return date;
+ }).ToList();
+ if(dates.Any(x=>x.HasValue))
+ series.EndDate = dates.Where(x => x.HasValue).Max();
+ }
}
///