Searching for movies directly when adding them is now working.

This commit is contained in:
Leonardo Galli 2017-01-03 13:26:09 +01:00
parent 329786365d
commit d835c168d3
7 changed files with 80 additions and 6 deletions

View File

@ -48,6 +48,7 @@ namespace NzbDrone.Api.Movie
public List<string> Genres { get; set; }
public HashSet<int> Tags { get; set; }
public DateTime Added { get; set; }
public AddMovieOptions AddOptions { get; set; }
public Ratings Ratings { get; set; }
//TODO: Add series statistics as a property of the series (instead of individual properties)
@ -110,6 +111,7 @@ namespace NzbDrone.Api.Movie
Genres = model.Genres,
Tags = model.Tags,
Added = model.Added,
AddOptions = model.AddOptions,
Ratings = model.Ratings
};
}
@ -152,6 +154,7 @@ namespace NzbDrone.Api.Movie
Genres = resource.Genres,
Tags = resource.Tags,
Added = resource.Added,
AddOptions = resource.AddOptions,
Ratings = resource.Ratings
};
}
@ -167,6 +170,7 @@ namespace NzbDrone.Api.Movie
movie.RootFolderPath = resource.RootFolderPath;
movie.Tags = resource.Tags;
movie.AddOptions = resource.AddOptions;
return movie;
}

View File

@ -63,7 +63,8 @@ namespace NzbDrone.Core.Datastore.Migration
.WithColumn("Ratings").AsString().Nullable()
.WithColumn("Genres").AsString().Nullable()
.WithColumn("Tags").AsString().Nullable()
.WithColumn("Certification").AsString().Nullable();
.WithColumn("Certification").AsString().Nullable()
.WithColumn("AddOptions").AsString().Nullable();
Create.TableForModel("Seasons")

View File

@ -1096,6 +1096,7 @@
<Compile Include="Tv\SeriesAddedHandler.cs" />
<Compile Include="Tv\MovieRepository.cs" />
<Compile Include="Tv\MovieEditedService.cs" />
<Compile Include="Tv\MovieScannedHandler.cs" />
<Compile Include="Tv\SeriesScannedHandler.cs" />
<Compile Include="Tv\SeriesEditedService.cs" />
<Compile Include="Tv\SeriesRepository.cs" />

View File

@ -40,11 +40,16 @@ namespace NzbDrone.Core.Tv
public DateTime? InCinemas { get; set; }
public LazyLoaded<Profile> Profile { get; set; }
public HashSet<int> Tags { get; set; }
// public AddMovieOptions AddOptions { get; set; }
public AddMovieOptions AddOptions { get; set; }
public override string ToString()
{
return string.Format("[{0}][{1}]", ImdbId, Title.NullSafe());
}
}
public class AddMovieOptions : MonitoringOptions
{
public bool SearchForMovie { get; set; }
}
}

View File

@ -0,0 +1,57 @@
using NLog;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Tv
{
public class MovieScannedHandler : IHandle<MovieScannedEvent>,
IHandle<MovieScanSkippedEvent>
{
private readonly IMovieService _movieService;
private readonly IManageCommandQueue _commandQueueManager;
private readonly Logger _logger;
public MovieScannedHandler( IMovieService movieService,
IManageCommandQueue commandQueueManager,
Logger logger)
{
_movieService = movieService;
_commandQueueManager = commandQueueManager;
_logger = logger;
}
private void HandleScanEvents(Movie movie)
{
if (movie.AddOptions == null)
{
//_episodeAddedService.SearchForRecentlyAdded(movie.Id);
return;
}
_logger.Info("[{0}] was recently added, performing post-add actions", movie.Title);
//_episodeMonitoredService.SetEpisodeMonitoredStatus(movie, movie.AddOptions);
if (movie.AddOptions.SearchForMovie)
{
_commandQueueManager.Push(new MoviesSearchCommand { MovieId = movie.Id});
}
movie.AddOptions = null;
_movieService.RemoveAddOptions(movie);
}
public void Handle(MovieScannedEvent message)
{
HandleScanEvents(message.Movie);
}
public void Handle(MovieScanSkippedEvent message)
{
HandleScanEvents(message.Movie);
}
}
}

View File

@ -27,6 +27,7 @@ namespace NzbDrone.Core.Tv
Movie UpdateMovie(Movie movie);
List<Movie> UpdateMovie(List<Movie> movie);
bool MoviePathExists(string folder);
void RemoveAddOptions(Movie movie);
}
public class MovieService : IMovieService
@ -190,5 +191,9 @@ namespace NzbDrone.Core.Tv
return _movieRepository.MoviePathExists(folder);
}
public void RemoveAddOptions(Movie movie)
{
_movieRepository.SetFields(movie, s => s.AddOptions);
}
}
}

View File

@ -153,14 +153,14 @@ var view = Marionette.ItemView.extend({
},
_addWithoutSearch : function() {
this._addMovies(true);
this._addMovies(false);
},
_addAndSearch : function() {
this._addMovies(true);
},
_addMovies : function(searchForMissingEpisodes) {
_addMovies : function(searchForMovie) {
var addButton = this.ui.addButton;
var addSearchButton = this.ui.addSearchButton;
@ -171,7 +171,8 @@ var view = Marionette.ItemView.extend({
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
var options = this._getAddMoviesOptions();
options.searchForMissingEpisodes = searchForMissingEpisodes;
options.searchForMovie = searchForMovie;
console.warn(searchForMovie);
this.model.set({
profileId : profile,
@ -186,7 +187,7 @@ var view = Marionette.ItemView.extend({
console.log(this.model.save);
console.log(promise);
if (searchForMissingEpisodes) {
if (searchForMovie) {
this.ui.addSearchButton.spinForPromise(promise);
}