From 2d3522593e2085eb6ab76a4981e5a93bae2bc837 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 24 Jun 2016 16:07:35 -0400 Subject: [PATCH] support nfo episode attributes --- .../Parsers/EpisodeNfoParser.cs | 42 +++++++++++++++++++ .../Savers/EpisodeNfoSaver.cs | 10 +++++ 2 files changed, 52 insertions(+) diff --git a/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs index 100ce7af9..6e3114fa1 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/EpisodeNfoParser.cs @@ -188,6 +188,48 @@ namespace MediaBrowser.XbmcMetadata.Parsers break; } + case "displayseason": + { + 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)) + { + if ((item.ParentIndexNumber ?? 0) == 0) + { + item.AirsBeforeSeasonNumber = rval; + } + } + } + + break; + } + + case "displayepisode": + { + 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)) + { + if ((item.ParentIndexNumber ?? 0) == 0) + { + item.AirsBeforeEpisodeNumber = rval; + } + } + } + + break; + } + default: base.FetchDataFromXmlNode(reader, itemResult); diff --git a/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs index 60d024072..7523ce6bf 100644 --- a/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/EpisodeNfoSaver.cs @@ -72,11 +72,21 @@ namespace MediaBrowser.XbmcMetadata.Savers { writer.WriteElementString("airsbefore_episode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture)); } + if (episode.AirsBeforeEpisodeNumber.HasValue) + { + writer.WriteElementString("displayepisode", episode.AirsBeforeEpisodeNumber.Value.ToString(UsCulture)); + } if (episode.AirsBeforeSeasonNumber.HasValue) { writer.WriteElementString("airsbefore_season", episode.AirsBeforeSeasonNumber.Value.ToString(UsCulture)); } + var season = episode.AiredSeasonNumber; + if (season.HasValue) + { + writer.WriteElementString("displayseason", season.Value.ToString(UsCulture)); + } + if (episode.DvdEpisodeNumber.HasValue) { writer.WriteElementString("DVD_episodenumber", episode.DvdEpisodeNumber.Value.ToString(UsCulture));