mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
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 @@ public CalendarFeedModule(IEpisodeService episodeService)
|
||||
private Response GetCalendarFeed()
|
||||
{
|
||||
var pastDays = 7;
|
||||
var futureDays = 28;
|
||||
var futureDays = 28;
|
||||
var start = DateTime.Today.AddDays(-pastDays);
|
||||
var end = DateTime.Today.AddDays(futureDays);
|
||||
var unmonitored = false;
|
||||
var premiersOnly = false;
|
||||
|
||||
// TODO: Remove start/end parameters in v3, they don't work well for iCal
|
||||
var queryStart = Request.Query.Start;
|
||||
@ -34,6 +35,7 @@ private Response GetCalendarFeed()
|
||||
var queryPastDays = Request.Query.PastDays;
|
||||
var queryFutureDays = Request.Query.FutureDays;
|
||||
var queryUnmonitored = Request.Query.Unmonitored;
|
||||
var queryPremiersOnly = Request.Query.PremiersOnly;
|
||||
|
||||
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
|
||||
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
|
||||
@ -55,11 +57,21 @@ private Response GetCalendarFeed()
|
||||
unmonitored = bool.Parse(queryUnmonitored.Value);
|
||||
}
|
||||
|
||||
if (queryPremiersOnly.HasValue)
|
||||
{
|
||||
premiersOnly = bool.Parse(queryPremiersOnly.Value);
|
||||
}
|
||||
|
||||
var episodes = _episodeService.EpisodesBetweenDates(start, end, unmonitored);
|
||||
var icalCalendar = new iCalendar();
|
||||
|
||||
foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value))
|
||||
{
|
||||
if (premiersOnly && (episode.SeasonNumber == 0 || episode.EpisodeNumber != 1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var occurrence = icalCalendar.Create<Event>();
|
||||
occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString();
|
||||
occurrence.Status = episode.HasFile ? EventStatus.Confirmed : EventStatus.Tentative;
|
||||
|
@ -6,16 +6,40 @@ module.exports = Marionette.Layout.extend({
|
||||
template : 'Calendar/CalendarFeedViewTemplate',
|
||||
|
||||
ui : {
|
||||
icalUrl : '.x-ical-url',
|
||||
icalCopy : '.x-ical-copy'
|
||||
includeUnmonitored : '.x-includeUnmonitored',
|
||||
premiersOnly : '.x-premiersOnly',
|
||||
icalUrl : '.x-ical-url',
|
||||
icalCopy : '.x-ical-copy',
|
||||
icalWebCal : '.x-ical-webcal'
|
||||
},
|
||||
|
||||
templateHelpers : {
|
||||
icalHttpUrl : window.location.protocol + '//' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?apikey=' + window.NzbDrone.ApiKey,
|
||||
icalWebCalUrl : 'webcal://' + window.location.host + StatusModel.get('urlBase') + '/feed/calendar/NzbDrone.ics?apikey=' + window.NzbDrone.ApiKey
|
||||
events : {
|
||||
'click .x-includeUnmonitored' : '_updateUrl',
|
||||
'click .x-premiersOnly' : '_updateUrl'
|
||||
},
|
||||
|
||||
onShow : function() {
|
||||
this._updateUrl();
|
||||
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="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">iCal feed</label>
|
||||
<div class="col-sm-1 col-sm-push-9 help-inline">
|
||||
<label class="col-sm-3 control-label">Include Unmonitored</label>
|
||||
|
||||
<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" />
|
||||
</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">
|
||||
<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">
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user