Series search added

pull/4/head
Mark McDowall 12 years ago
parent 125f3d87a4
commit d19e33f0a8

@ -0,0 +1,9 @@
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.IndexerSearch
{
public class SeriesSearchCommand : ICommand
{
public int SeriesId { get; set; }
}
}

@ -0,0 +1,37 @@
using System.Linq;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Download;
using NzbDrone.Core.Tv;
namespace NzbDrone.Core.IndexerSearch
{
public class SeriesSearchService : IExecute<SeriesSearchCommand>
{
private readonly ISeasonService _seasonService;
private readonly ISearchForNzb _nzbSearchService;
private readonly IDownloadApprovedReports _downloadApprovedReports;
public SeriesSearchService(ISeasonService seasonService,
ISearchForNzb nzbSearchService,
IDownloadApprovedReports downloadApprovedReports)
{
_seasonService = seasonService;
_nzbSearchService = nzbSearchService;
_downloadApprovedReports = downloadApprovedReports;
}
public void Execute(SeriesSearchCommand message)
{
var seasons = _seasonService.GetSeasonsBySeries(message.SeriesId)
.Where(s => s.SeasonNumber > 0)
.OrderBy(s => s.SeasonNumber)
.ToList();
foreach (var season in seasons)
{
var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber);
_downloadApprovedReports.DownloadApproved(decisions);
}
}
}
}

@ -255,6 +255,8 @@
<Compile Include="Download\DownloadClientProvider.cs" /> <Compile Include="Download\DownloadClientProvider.cs" />
<Compile Include="Download\DownloadClientType.cs" /> <Compile Include="Download\DownloadClientType.cs" />
<Compile Include="Download\SabQueueItem.cs" /> <Compile Include="Download\SabQueueItem.cs" />
<Compile Include="IndexerSearch\SeriesSearchService.cs" />
<Compile Include="IndexerSearch\SeriesSearchCommand.cs" />
<Compile Include="IndexerSearch\EpisodeSearchService.cs" /> <Compile Include="IndexerSearch\EpisodeSearchService.cs" />
<Compile Include="IndexerSearch\EpisodeSearchCommand.cs" /> <Compile Include="IndexerSearch\EpisodeSearchCommand.cs" />
<Compile Include="IndexerSearch\SeasonSearchCommand.cs" /> <Compile Include="IndexerSearch\SeasonSearchCommand.cs" />

@ -95,13 +95,14 @@ define(
_seasonSearch: function () { _seasonSearch: function () {
Actioneer.ExecuteCommand({ Actioneer.ExecuteCommand({
command : 'seasonSearch', command : 'seasonSearch',
properties : { properties : {
seriesId : this.model.get('seriesId'), seriesId : this.model.get('seriesId'),
seasonNumber: this.model.get('seasonNumber') seasonNumber: this.model.get('seasonNumber')
}, },
element : this.ui.seasonSearch, element : this.ui.seasonSearch,
failMessage: 'Season search failed' failMessage : 'Search for season {0} failed'.format(this.model.get('seasonNumber')),
startMessage: 'Search for season {0} started'.format(this.model.get('seasonNumber'))
}); });
}, },

@ -25,14 +25,16 @@ define(
monitored: '.x-monitored', monitored: '.x-monitored',
edit : '.x-edit', edit : '.x-edit',
refresh : '.x-refresh', refresh : '.x-refresh',
rename : '.x-rename' rename : '.x-rename',
search : '.x-search'
}, },
events: { events: {
'click .x-monitored': '_toggleMonitored', 'click .x-monitored': '_toggleMonitored',
'click .x-edit' : '_editSeries', 'click .x-edit' : '_editSeries',
'click .x-refresh' : '_refreshSeries', 'click .x-refresh' : '_refreshSeries',
'click .x-rename' : '_renameSeries' 'click .x-rename' : '_renameSeries',
'click .x-search' : '_seriesSearch'
}, },
initialize: function () { initialize: function () {
@ -146,6 +148,18 @@ define(
element : this.ui.rename, element : this.ui.rename,
failMessage: 'Series search failed' failMessage: 'Series search failed'
}); });
},
_seriesSearch: function () {
Actioneer.ExecuteCommand({
command : 'seriesSearch',
properties : {
seriesId : this.model.get('id')
},
element : this.ui.search,
failMessage : 'Series search failed',
startMessage: 'Search for {0} started'.format(this.model.get('title'))
});
} }
}); });
}); });

@ -5,8 +5,9 @@
<i class="icon-bookmark x-monitored clickable" title="Toggle monitored state for entire series"/> <i class="icon-bookmark x-monitored clickable" title="Toggle monitored state for entire series"/>
{{title}} {{title}}
<span class="series-actions pull-right"> <span class="series-actions pull-right">
<i class="icon-nd-rename x-rename" title="Rename Series"/> <i class="icon-refresh x-refresh" title="Update series info and scan disk"/>
<i class="icon-refresh x-refresh" title="Update Series"/> <i class="icon-nd-rename x-rename" title="Rename all episodes in this series"/>
<i class="icon-search x-search" title="Search for all episodes in this series"/>
<i class="icon-nd-edit x-edit" title="Edit series"/> <i class="icon-nd-edit x-edit" title="Edit series"/>
</span> </span>
</h1> </h1>

@ -5,6 +5,7 @@ define(['Commands/CommandController', 'Shared/Messenger'],
ExecuteCommand: function (options) { ExecuteCommand: function (options) {
options.iconClass = this._getIconClass(options.element); options.iconClass = this._getIconClass(options.element);
this._showStartMessage(options);
this._setSpinnerOnElement(options); this._setSpinnerOnElement(options);
var promise = CommandController.Execute(options.command, options.properties); var promise = CommandController.Execute(options.command, options.properties);
@ -14,9 +15,10 @@ define(['Commands/CommandController', 'Shared/Messenger'],
SaveModel: function (options) { SaveModel: function (options) {
options.iconClass = this._getIconClass(options.element); options.iconClass = this._getIconClass(options.element);
this._showStartMessage(options);
this._setSpinnerOnElement(options); this._setSpinnerOnElement(options);
var promise = options.context.model.save();
var promise = options.context.model.save();
this._handlePromise(promise, options); this._handlePromise(promise, options);
}, },
@ -80,6 +82,14 @@ define(['Commands/CommandController', 'Shared/Messenger'],
options.element.removeClass(options.iconClass); options.element.removeClass(options.iconClass);
options.element.addClass('icon-nd-spinner'); options.element.addClass('icon-nd-spinner');
} }
},
_showStartMessage: function (options) {
if (options.startMessage) {
Messenger.show({
message: options.startMessage
});
}
} }
} }
}); });

Loading…
Cancel
Save