diff --git a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs index 60aa37e28..0e62517f9 100644 --- a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs @@ -2,7 +2,11 @@ using System; using System.Collections.Generic; using System.Linq; -using DDay.iCal; +using Ical.Net; +using Ical.Net.DataTypes; +using Ical.Net.Interfaces.Serialization; +using Ical.Net.Serialization; +using Ical.Net.Serialization.iCalendar.Factory; using NzbDrone.Core.Tv; using Nancy.Responses; using NzbDrone.Core.Tags; @@ -22,6 +26,7 @@ namespace NzbDrone.Api.Calendar _tagService = tagService; Get["/NzbDrone.ics"] = options => GetCalendarFeed(); + Get["/Sonarr.ics"] = options => GetCalendarFeed(); } private Response GetCalendarFeed() @@ -75,7 +80,12 @@ namespace NzbDrone.Api.Calendar } var episodes = _episodeService.EpisodesBetweenDates(start, end, unmonitored); - var icalCalendar = new iCalendar(); + var calendar = new Ical.Net.Calendar + { + ProductId = "-//sonarr.tv//Sonarr//EN" + }; + + foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value)) { @@ -89,28 +99,27 @@ namespace NzbDrone.Api.Calendar continue; } - var occurrence = icalCalendar.Create(); - occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString(); + var occurrence = calendar.Create(); + occurrence.Uid = "NzbDrone_episode_" + episode.Id; occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative; - occurrence.Start = new iCalDateTime(episode.AirDateUtc.Value) { HasTime = true }; - occurrence.End = new iCalDateTime(episode.AirDateUtc.Value.AddMinutes(episode.Series.Runtime)) { HasTime = true }; + occurrence.Start = new CalDateTime(episode.AirDateUtc.Value) { HasTime = true }; + occurrence.End = new CalDateTime(episode.AirDateUtc.Value.AddMinutes(episode.Series.Runtime)) { HasTime = true }; occurrence.Description = episode.Overview; occurrence.Categories = new List() { episode.Series.Network }; switch (episode.Series.SeriesType) { case SeriesTypes.Daily: - occurrence.Summary = string.Format("{0} - {1}", episode.Series.Title, episode.Title); + occurrence.Summary = $"{episode.Series.Title} - {episode.Title}"; break; - default: - occurrence.Summary = string.Format("{0} - {1}x{2:00} - {3}", episode.Series.Title, episode.SeasonNumber, episode.EpisodeNumber, episode.Title); + occurrence.Summary =$"{episode.Series.Title} - {episode.SeasonNumber}x{episode.EpisodeNumber:00} - {episode.Title}"; break; } } - var serializer = new DDay.iCal.Serialization.iCalendar.SerializerFactory().Build(icalCalendar.GetType(), new DDay.iCal.Serialization.SerializationContext()) as DDay.iCal.Serialization.IStringSerializer; - var icalendar = serializer.SerializeToString(icalCalendar); + var serializer = (IStringSerializer) new SerializerFactory().Build(calendar.GetType(), new SerializationContext()); + var icalendar = serializer.SerializeToString(calendar); return new TextResponse(icalendar, "text/calendar"); } diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index ebac8f273..4ade4bcdf 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -40,10 +40,22 @@ 4 + + ..\packages\Ical.Net.2.2.25\lib\net40\antlr.runtime.dll + True + ..\packages\FluentValidation.6.2.1.0\lib\portable-net40+sl50+wp80+win8+wpa81\FluentValidation.dll True + + ..\packages\Ical.Net.2.2.25\lib\net40\Ical.Net.dll + True + + + ..\packages\Ical.Net.2.2.25\lib\net40\Ical.Net.Collections.dll + True + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll True @@ -64,13 +76,14 @@ ..\packages\NLog.4.3.11\lib\net40\NLog.dll True + + ..\packages\Ical.Net.2.2.25\lib\net40\NodaTime.dll + True + - - ..\packages\DDay.iCal.1.0.2.575\lib\DDay.iCal.dll - False ..\Libraries\Sqlite\System.Data.SQLite.dll diff --git a/src/NzbDrone.Api/packages.config b/src/NzbDrone.Api/packages.config index ca750d07e..b6b75f2bd 100644 --- a/src/NzbDrone.Api/packages.config +++ b/src/NzbDrone.Api/packages.config @@ -1,7 +1,7 @@  - +