Merge pull request #373 from baltoaca/develop

search selected button in wanted tab works
pull/378/head
Devin Buhl 8 years ago committed by GitHub
commit 0ec54daaff

@ -5,6 +5,7 @@ using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
using System.Collections.Generic;
namespace NzbDrone.Core.Download
{
@ -38,7 +39,7 @@ namespace NzbDrone.Core.Download
{
_logger.Debug("Failed download contains a movie, searching again.");
_commandQueueManager.Push(new MoviesSearchCommand { MovieId = message.MovieId });
_commandQueueManager.Push(new MoviesSearchCommand { MovieIds = new List<int> { message.MovieId } });
return;
}

@ -0,0 +1,13 @@
using NzbDrone.Core.Messaging.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.IndexerSearch
{
public class MissingMoviesSearchCommand : Command
{
public override bool SendUpdatesToClient => true;
}
}

@ -1,10 +1,11 @@
using NzbDrone.Core.Messaging.Commands;
using System.Collections.Generic;
namespace NzbDrone.Core.IndexerSearch
{
public class MoviesSearchCommand : Command
{
public int MovieId { get; set; }
public List<int> MovieIds { get; set; }
public override bool SendUpdatesToClient => true;
}

@ -4,22 +4,23 @@ using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Download;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Core.IndexerSearch
{
public class MovieSearchService : IExecute<MoviesSearchCommand>
public class MovieSearchService : IExecute<MoviesSearchCommand>, IExecute<MissingMoviesSearchCommand>
{
private readonly IMovieService _seriesService;
private readonly IMovieService _movieService;
private readonly ISearchForNzb _nzbSearchService;
private readonly IProcessDownloadDecisions _processDownloadDecisions;
private readonly Logger _logger;
public MovieSearchService(IMovieService seriesService,
public MovieSearchService(IMovieService movieService,
ISearchForNzb nzbSearchService,
IProcessDownloadDecisions processDownloadDecisions,
Logger logger)
{
_seriesService = seriesService;
_movieService = movieService;
_nzbSearchService = nzbSearchService;
_processDownloadDecisions = processDownloadDecisions;
_logger = logger;
@ -27,20 +28,35 @@ namespace NzbDrone.Core.IndexerSearch
public void Execute(MoviesSearchCommand message)
{
var series = _seriesService.GetMovie(message.MovieId);
var downloadedCount = 0;
foreach (var movieId in message.MovieIds)
{
var series = _movieService.GetMovie(movieId);
if (!series.Monitored)
{
_logger.Debug("Movie {0} is not monitored, skipping search", series.Title);
}
var decisions = _nzbSearchService.MovieSearch(message.MovieId, false);//_nzbSearchService.SeasonSearch(message.MovieId, season.SeasonNumber, false, message.Trigger == CommandTrigger.Manual);
var decisions = _nzbSearchService.MovieSearch(movieId, false);//_nzbSearchService.SeasonSearch(message.MovieId, season.SeasonNumber, false, message.Trigger == CommandTrigger.Manual);
downloadedCount += _processDownloadDecisions.ProcessDecisions(decisions).Grabbed.Count;
}
_logger.ProgressInfo("Movie search completed. {0} reports downloaded.", downloadedCount);
}
public void Execute(MissingMoviesSearchCommand message)
{
var movies = _movieService.MoviesWithoutFiles(new PagingSpec<Movie>
{
Page = 1,
PageSize = 100000,
SortDirection = SortDirection.Ascending,
SortKey = "Id",
FilterExpression =
v =>
v.Monitored == true
}).Records.ToList();
}
}
}

@ -583,6 +583,7 @@
<Compile Include="Http\HttpProxySettingsProvider.cs" />
<Compile Include="Http\TorcacheHttpInterceptor.cs" />
<Compile Include="IndexerSearch\Definitions\MovieSearchCriteria.cs" />
<Compile Include="IndexerSearch\MissingMoviesSearchCommand.cs" />
<Compile Include="IndexerSearch\MoviesSearchCommand.cs" />
<Compile Include="IndexerSearch\MoviesSearchService.cs" />
<Compile Include="Indexers\AwesomeHD\AwesomeHDRssParser.cs" />

@ -3,6 +3,7 @@ using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using System.Collections.Generic;
namespace NzbDrone.Core.Tv
{
@ -37,7 +38,7 @@ namespace NzbDrone.Core.Tv
if (movie.AddOptions.SearchForMovie)
{
_commandQueueManager.Push(new MoviesSearchCommand { MovieId = movie.Id});
_commandQueueManager.Push(new MoviesSearchCommand { MovieIds = new List<int> { movie.Id } });
}
movie.AddOptions = null;

@ -209,7 +209,7 @@ module.exports = Marionette.Layout.extend({
_moviesSearch : function() {
CommandController.Execute('moviesSearch', {
name : 'moviesSearch',
movieId : this.model.id
movieIds : [this.model.id]
});
},

@ -165,11 +165,11 @@ module.exports = Marionette.Layout.extend({
}));
CommandController.bindToCommand({
element : this.$('.x-search-selected'),
command : { name : 'episodeSearch' }
command : { name : 'moviesSearch' }
});
CommandController.bindToCommand({
element : this.$('.x-search-missing'),
command : { name : 'missingEpisodeSearch' }
command : { name : 'missingMoviesSearch' }
});
},
@ -187,20 +187,20 @@ module.exports = Marionette.Layout.extend({
if (selected.length === 0) {
Messenger.show({
type : 'error',
message : 'No episodes selected'
message : 'No movies selected'
});
return;
}
var ids = _.pluck(selected, 'id');
CommandController.Execute('episodeSearch', {
name : 'episodeSearch',
episodeIds : ids
CommandController.Execute('moviesSearch', {
name : 'moviesSearch',
movieIds : ids
});
},
_searchMissing : function() {
if (window.confirm('Are you sure you want to search for {0} missing movies? '.format(this.collection.state.totalRecords) +
'One API request to each indexer will be used for each movie. ' + 'This cannot be stopped once started.')) {
CommandController.Execute('missingEpisodeSearch', { name : 'missingEpisodeSearch' });
CommandController.Execute('missingMoviesSearch', { name : 'missingMoviesSearch' });
}
},
_toggleMonitoredOfSelected : function() {
@ -209,7 +209,7 @@ module.exports = Marionette.Layout.extend({
if (selected.length === 0) {
Messenger.show({
type : 'error',
message : 'No episodes selected'
message : 'No movies selected'
});
return;
}

Loading…
Cancel
Save