New: Added query parameter to ical feed to list premiers only.
fixes #1463 fixes #1442
This commit is contained in:
parent
e3310e590c
commit
080e2e9eff
|
@ -23,10 +23,11 @@ namespace NzbDrone.Api.Calendar
|
||||||
private Response GetCalendarFeed()
|
private Response GetCalendarFeed()
|
||||||
{
|
{
|
||||||
var pastDays = 7;
|
var pastDays = 7;
|
||||||
var futureDays = 28;
|
var futureDays = 28;
|
||||||
var start = DateTime.Today.AddDays(-pastDays);
|
var start = DateTime.Today.AddDays(-pastDays);
|
||||||
var end = DateTime.Today.AddDays(futureDays);
|
var end = DateTime.Today.AddDays(futureDays);
|
||||||
var unmonitored = false;
|
var unmonitored = false;
|
||||||
|
var premiersOnly = false;
|
||||||
|
|
||||||
// TODO: Remove start/end parameters in v3, they don't work well for iCal
|
// TODO: Remove start/end parameters in v3, they don't work well for iCal
|
||||||
var queryStart = Request.Query.Start;
|
var queryStart = Request.Query.Start;
|
||||||
|
@ -34,6 +35,7 @@ namespace NzbDrone.Api.Calendar
|
||||||
var queryPastDays = Request.Query.PastDays;
|
var queryPastDays = Request.Query.PastDays;
|
||||||
var queryFutureDays = Request.Query.FutureDays;
|
var queryFutureDays = Request.Query.FutureDays;
|
||||||
var queryUnmonitored = Request.Query.Unmonitored;
|
var queryUnmonitored = Request.Query.Unmonitored;
|
||||||
|
var queryPremiersOnly = Request.Query.PremiersOnly;
|
||||||
|
|
||||||
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
|
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
|
||||||
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
|
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
|
||||||
|
@ -55,11 +57,21 @@ namespace NzbDrone.Api.Calendar
|
||||||
unmonitored = bool.Parse(queryUnmonitored.Value);
|
unmonitored = bool.Parse(queryUnmonitored.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queryPremiersOnly.HasValue)
|
||||||
|
{
|
||||||
|
premiersOnly = bool.Parse(queryPremiersOnly.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var episodes = _episodeService.EpisodesBetweenDates(start, end, unmonitored);
|
var episodes = _episodeService.EpisodesBetweenDates(start, end, unmonitored);
|
||||||
var icalCalendar = new iCalendar();
|
var icalCalendar = new iCalendar();
|
||||||
|
|
||||||
foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value))
|
foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value))
|
||||||
{
|
{
|
||||||
|
if (premiersOnly && (episode.SeasonNumber == 0 || episode.EpisodeNumber != 1))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var occurrence = icalCalendar.Create<Event>();
|
var occurrence = icalCalendar.Create<Event>();
|
||||||
occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString();
|
occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString();
|
||||||
occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
||||||
|
|
|
@ -6,16 +6,40 @@ module.exports = Marionette.Layout.extend({
|
||||||
template : 'Calendar/CalendarFeedViewTemplate',
|
template : 'Calendar/CalendarFeedViewTemplate',
|
||||||
|
|
||||||
ui : {
|
ui : {
|
||||||
icalUrl : '.x-ical-url',
|
includeUnmonitored : '.x-includeUnmonitored',
|
||||||
icalCopy : '.x-ical-copy'
|
premiersOnly : '.x-premiersOnly',
|
||||||
|
icalUrl : '.x-ical-url',
|
||||||
|
icalCopy : '.x-ical-copy',
|
||||||
|
icalWebCal : '.x-ical-webcal'
|
||||||
},
|
},
|
||||||
|
|
||||||
templateHelpers : {
|
events : {
|
||||||
icalHttpUrl : window.location.protocol + '//' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?apikey=' + window.NzbDrone.ApiKey,
|
'click .x-includeUnmonitored' : '_updateUrl',
|
||||||
icalWebCalUrl : 'webcal://' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?apikey=' + window.NzbDrone.ApiKey
|
'click .x-premiersOnly' : '_updateUrl'
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow : function() {
|
onShow : function() {
|
||||||
|
this._updateUrl();
|
||||||
this.ui.icalCopy.copyToClipboard(this.ui.icalUrl);
|
this.ui.icalCopy.copyToClipboard(this.ui.icalUrl);
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateUrl : function() {
|
||||||
|
var icalUrl = window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?';
|
||||||
|
|
||||||
|
if (this.ui.includeUnmonitored.prop('checked')) {
|
||||||
|
icalUrl += 'unmonitored=true&';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.ui.premiersOnly.prop('checked')) {
|
||||||
|
icalUrl += 'premiersOnly=true&';
|
||||||
|
}
|
||||||
|
|
||||||
|
icalUrl += 'apikey=' + window.NzbDrone.ApiKey;
|
||||||
|
|
||||||
|
var icalHttpUrl = window.location.protocol + '//' + icalUrl;
|
||||||
|
var icalWebCalUrl = 'webcal://' + icalUrl;
|
||||||
|
|
||||||
|
this.ui.icalUrl.attr('value', icalHttpUrl);
|
||||||
|
this.ui.icalWebCal.attr('href', icalWebCalUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -6,16 +6,52 @@
|
||||||
<div class="modal-body edit-series-modal">
|
<div class="modal-body edit-series-modal">
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label">iCal feed</label>
|
<label class="col-sm-3 control-label">Include Unmonitored</label>
|
||||||
<div class="col-sm-1 col-sm-push-9 help-inline">
|
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="input-group">
|
||||||
|
<label class="checkbox toggle well">
|
||||||
|
<input type="checkbox" name="includeUnmonitored" class="form-control x-includeUnmonitored"/>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<span>Yes</span>
|
||||||
|
<span>No</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="btn btn-primary slide-button"/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">Season Premiers Only</label>
|
||||||
|
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="input-group">
|
||||||
|
<label class="checkbox toggle well">
|
||||||
|
<input type="checkbox" name="premiersOnly" class="form-control x-premiersOnly"/>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<span>Yes</span>
|
||||||
|
<span>No</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="btn btn-primary slide-button"/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">iCal feed</label>
|
||||||
|
<div class="col-sm-1 col-sm-push-8 help-inline">
|
||||||
<i class="icon-sonarr-form-info" title="Copy this url into your clients subscription form or use the subscribe button if your browser support webcal" />
|
<i class="icon-sonarr-form-info" title="Copy this url into your clients subscription form or use the subscribe button if your browser support webcal" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-9 col-sm-pull-1">
|
<div class="col-sm-8 col-sm-pull-1">
|
||||||
<div class="input-group ical-url">
|
<div class="input-group ical-url">
|
||||||
<input type="text" class="form-control x-ical-url" value="{{icalHttpUrl}}" readonly="readonly" />
|
<input type="text" class="form-control x-ical-url" readonly="readonly" />
|
||||||
<div class="input-group-btn">
|
<div class="input-group-btn">
|
||||||
<button class="btn btn-icon-only x-ical-copy"><i class="icon-sonarr-copy"></i></button>
|
<button class="btn btn-icon-only x-ical-copy"><i class="icon-sonarr-copy"></i></button>
|
||||||
<button class="btn btn-icon-only no-router" title="Subscribe" href="{{icalWebCalUrl}}" target="_blank"><i class="icon-sonarr-calendar-o"></i></button>
|
<button class="btn btn-icon-only no-router x-ical-webcal" title="Subscribe" target="_blank"><i class="icon-sonarr-calendar-o"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue