diff --git a/src/NzbDrone.Core/Datastore/Migration/137_add_airedbefore_to_episodes.cs b/src/NzbDrone.Core/Datastore/Migration/137_add_airedbefore_to_episodes.cs new file mode 100644 index 000000000..aad2365a0 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/137_add_airedbefore_to_episodes.cs @@ -0,0 +1,16 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(137)] + public class add_airedbefore_to_episodes : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Episodes").AddColumn("AiredAfterSeasonNumber").AsInt32().Nullable() + .AddColumn("AiredBeforeSeasonNumber").AsInt32().Nullable() + .AddColumn("AiredBeforeEpisodeNumber").AsInt32().Nullable(); + } + } +} diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index 091a3c48b..10e064980 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -255,10 +255,16 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc details.Add(new XElement("aired", episode.AirDate)); details.Add(new XElement("plot", episode.Overview)); - //If trakt ever gets airs before information for specials we should add set it - details.Add(new XElement("displayseason")); - details.Add(new XElement("displayepisode")); - + if (episode.SeasonNumber == 0 && episode.AiredAfterSeasonNumber.HasValue) + { + details.Add(new XElement("displayafterseason", episode.AiredAfterSeasonNumber)); + } + else if (episode.SeasonNumber == 0 && episode.AiredBeforeSeasonNumber.HasValue) + { + details.Add(new XElement("displayseason", episode.AiredBeforeSeasonNumber)); + details.Add(new XElement("displayepisode", episode.AiredBeforeEpisodeNumber ?? -1)); + } + var uniqueId = new XElement("uniqueid", episode.Id); uniqueId.SetAttributeValue("type", "sonarr"); uniqueId.SetAttributeValue("default", true); diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/EpisodeResource.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/EpisodeResource.cs index acaffe418..651cf27df 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/EpisodeResource.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/Resource/EpisodeResource.cs @@ -7,6 +7,9 @@ namespace NzbDrone.Core.MetadataSource.SkyHook.Resource public int SeasonNumber { get; set; } public int EpisodeNumber { get; set; } public int? AbsoluteEpisodeNumber { get; set; } + public int? AiredAfterSeasonNumber { get; set; } + public int? AiredBeforeSeasonNumber { get; set; } + public int? AiredBeforeEpisodeNumber { get; set; } public string Title { get; set; } public string AirDate { get; set; } public DateTime? AirDateUtc { get; set; } diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 9f7c978ca..db5b96264 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -222,6 +222,9 @@ namespace NzbDrone.Core.MetadataSource.SkyHook episode.EpisodeNumber = oracleEpisode.EpisodeNumber; episode.AbsoluteEpisodeNumber = oracleEpisode.AbsoluteEpisodeNumber; episode.Title = oracleEpisode.Title; + episode.AiredAfterSeasonNumber = oracleEpisode.AiredAfterSeasonNumber; + episode.AiredBeforeSeasonNumber = oracleEpisode.AiredBeforeSeasonNumber; + episode.AiredBeforeEpisodeNumber = oracleEpisode.AiredBeforeEpisodeNumber; episode.AirDate = oracleEpisode.AirDate; episode.AirDateUtc = oracleEpisode.AirDateUtc; diff --git a/src/NzbDrone.Core/Tv/Episode.cs b/src/NzbDrone.Core/Tv/Episode.cs index 15efc7996..a54563fb9 100644 --- a/src/NzbDrone.Core/Tv/Episode.cs +++ b/src/NzbDrone.Core/Tv/Episode.cs @@ -29,6 +29,9 @@ namespace NzbDrone.Core.Tv public int? SceneAbsoluteEpisodeNumber { get; set; } public int? SceneSeasonNumber { get; set; } public int? SceneEpisodeNumber { get; set; } + public int? AiredAfterSeasonNumber { get; set; } + public int? AiredBeforeSeasonNumber { get; set; } + public int? AiredBeforeEpisodeNumber { get; set; } public bool UnverifiedSceneNumbering { get; set; } public Ratings Ratings { get; set; } public List Images { get; set; } diff --git a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs index 843fffa18..3fd982b8b 100644 --- a/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs +++ b/src/NzbDrone.Core/Tv/RefreshEpisodeService.cs @@ -66,6 +66,9 @@ namespace NzbDrone.Core.Tv episodeToUpdate.EpisodeNumber = episode.EpisodeNumber; episodeToUpdate.SeasonNumber = episode.SeasonNumber; episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteEpisodeNumber; + episodeToUpdate.AiredAfterSeasonNumber = episode.AiredAfterSeasonNumber; + episodeToUpdate.AiredBeforeSeasonNumber = episode.AiredBeforeSeasonNumber; + episodeToUpdate.AiredBeforeEpisodeNumber = episode.AiredBeforeEpisodeNumber; episodeToUpdate.Title = episode.Title ?? "TBA"; episodeToUpdate.Overview = episode.Overview; episodeToUpdate.AirDate = episode.AirDate;