Patch/onedr0p updates (#998)

* few small things

* update var names

* Validate Root Folder, Minimum Avability and ProfileId on List import.
Devin Buhl 8 years ago committed by GitHub
parent f7bc889723
commit aab425ee5b

@ -1,16 +1,17 @@
using NzbDrone.Api.ClientSchema;
using FluentValidation;
using NzbDrone.Api.ClientSchema;
using NzbDrone.Core.NetImport;
using NzbDrone.Core.Profiles;
using NzbDrone.Core.Validation.Paths;
namespace NzbDrone.Api.NetImport
{
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
{
private readonly IProfileService _profileService;
public NetImportModule(NetImportFactory indexerFactory, IProfileService profileService)
: base(indexerFactory, "netimport")
public NetImportModule(NetImportFactory netImportFactory) : base(netImportFactory, "netimport")
{
_profileService = profileService;
PostValidator.RuleFor(c => c.RootFolderPath).NotNull();
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
PostValidator.RuleFor(c => c.ProfileId).NotNull();
}
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)

@ -119,7 +119,7 @@ namespace NzbDrone.Api
resource.Fields = SchemaBuilder.ToSchema(definition.Settings);
resource.InfoLink = string.Format("https://github.com/Sonarr/Sonarr/wiki/Supported-{0}#{1}",
resource.InfoLink = string.Format("https://github.com/Radarr/Radarr/wiki/Supported-{0}#{1}",
typeof(TProviderResource).Name.Replace("Resource", "s"),
definition.Implementation.ToLower());
}

@ -1,8 +1,4 @@
using NzbDrone.Core.Messaging.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.IndexerSearch
{

@ -33,44 +33,16 @@ namespace NzbDrone.Core.IndexerSearch
_logger = logger;
}
private void SearchForMissingMovies(List<Movie> movies, bool userInvokedSearch)
{
_logger.ProgressInfo("Performing missing search for {0} movies", movies.Count);
var downloadedCount = 0;
foreach (var movieId in movies.GroupBy(e => e.Id))
{
List<DownloadDecision> decisions;
try
{
decisions = _nzbSearchService.MovieSearch(movieId.Key, userInvokedSearch);
}
catch (Exception ex)
{
var message = String.Format("Unable to search for missing movie {0}", movieId.Key);
_logger.Error(ex, message);
continue;
}
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
downloadedCount += processed.Grabbed.Count;
}
_logger.ProgressInfo("Completed missing search for {0} movies. {1} reports downloaded.", movies.Count, downloadedCount);
}
public void Execute(MoviesSearchCommand message)
{
var downloadedCount = 0;
foreach (var movieId in message.MovieIds)
{
var series = _movieService.GetMovie(movieId);
var movies = _movieService.GetMovie(movieId);
if (!series.Monitored)
if (!movies.Monitored)
{
_logger.Debug("Movie {0} is not monitored, skipping search", series.Title);
_logger.Debug("Movie {0} is not monitored, skipping search", movies.Title);
}
var decisions = _nzbSearchService.MovieSearch(movieId, false);//_nzbSearchService.SeasonSearch(message.MovieId, season.SeasonNumber, false, message.Trigger == CommandTrigger.Manual);
@ -82,9 +54,7 @@ namespace NzbDrone.Core.IndexerSearch
public void Execute(MissingMoviesSearchCommand message)
{
List<Movie> movies;
movies = _movieService.MoviesWithoutFiles(new PagingSpec<Movie>
List<Movie> movies = _movieService.MoviesWithoutFiles(new PagingSpec<Movie>
{
Page = 1,
PageSize = 100000,
@ -101,5 +71,35 @@ namespace NzbDrone.Core.IndexerSearch
}
private void SearchForMissingMovies(List<Movie> movies, bool userInvokedSearch)
{
_logger.ProgressInfo("Performing missing search for {0} movies", movies.Count);
var downloadedCount = 0;
foreach (var movieId in movies.GroupBy(e => e.Id))
{
List<DownloadDecision> decisions;
try
{
decisions = _nzbSearchService.MovieSearch(movieId.Key, userInvokedSearch);
}
catch (Exception ex)
{
var message = String.Format("Unable to search for missing movie {0}", movieId.Key);
_logger.Error(ex, message);
continue;
}
var processed = _processDownloadDecisions.ProcessDecisions(decisions);
downloadedCount += processed.Grabbed.Count;
}
_logger.ProgressInfo("Completed missing search for {0} movies. {1} reports downloaded.", movies.Count, downloadedCount);
}
}
}

@ -74,14 +74,14 @@ namespace NzbDrone.Core.MediaFiles
_eventAggregator.PublishEvent(new EpisodeFileDeletedEvent(episodeFile, reason));
}
public void Delete(MovieFile episodeFile, DeleteMediaFileReason reason)
public void Delete(MovieFile movieFile, DeleteMediaFileReason reason)
{
//Little hack so we have the episodes and series attached for the event consumers
episodeFile.Movie.LazyLoad();
episodeFile.Path = Path.Combine(episodeFile.Movie.Value.Path, episodeFile.RelativePath);
movieFile.Movie.LazyLoad();
movieFile.Path = Path.Combine(movieFile.Movie.Value.Path, movieFile.RelativePath);
_movieFileRepository.Delete(episodeFile);
_eventAggregator.PublishEvent(new MovieFileDeletedEvent(episodeFile, reason));
_movieFileRepository.Delete(movieFile);
_eventAggregator.PublishEvent(new MovieFileDeletedEvent(movieFile, reason));
}
public List<EpisodeFile> GetFilesBySeries(int seriesId)
@ -153,9 +153,9 @@ namespace NzbDrone.Core.MediaFiles
return addedFile;
}
public void Update(MovieFile episodeFile)
public void Update(MovieFile movieFile)
{
_movieFileRepository.Update(episodeFile);
_movieFileRepository.Update(movieFile);
}
public MovieFile GetMovie(int id)

@ -89,7 +89,15 @@
<label class="col-sm-3 control-label">Folder</label>
<div class="col-sm-5">
{{> RootFolderSelectionPartial rootFolders}}
<select class="col-md-4 form-control x-root-folder" name="RootFolderPath">
{{#if rootFolders}}
{{#each rootFolders}}
<option value="{{id}}">{{path}}</option>
{{/each}}
{{else}}
<option value="">Select Path</option>
{{/if}}
</select>
</div>
</div>

@ -103,7 +103,7 @@ module.exports = Marionette.Layout.extend({
icon : 'icon-sonarr-search',
callback : this._searchMissing,
ownerContext : this,
className : 'x-search-missing'
className : 'x-search-cutoff'
},
]
};
@ -182,6 +182,11 @@ module.exports = Marionette.Layout.extend({
name : 'moviesSearch'
}
});
CommandController.bindToCommand({
element : this.$('.x-search-cutoff'),
command : { name : 'missingMoviesSearch' }
});
},
_setFilter : function(buttonContext) {

Loading…
Cancel
Save