mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 09:49:00 +00:00
Searching for movies directly when adding them is now working.
This commit is contained in:
parent
329786365d
commit
d835c168d3
7 changed files with 80 additions and 6 deletions
|
@ -48,6 +48,7 @@ public MovieResource()
|
|||
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 @@ public static MovieResource ToResource(this Core.Tv.Movie model)
|
|||
Genres = model.Genres,
|
||||
Tags = model.Tags,
|
||||
Added = model.Added,
|
||||
AddOptions = model.AddOptions,
|
||||
Ratings = model.Ratings
|
||||
};
|
||||
}
|
||||
|
@ -152,6 +154,7 @@ public static Core.Tv.Movie ToModel(this MovieResource resource)
|
|||
Genres = resource.Genres,
|
||||
Tags = resource.Tags,
|
||||
Added = resource.Added,
|
||||
AddOptions = resource.AddOptions,
|
||||
Ratings = resource.Ratings
|
||||
};
|
||||
}
|
||||
|
@ -167,6 +170,7 @@ public static Core.Tv.Movie ToModel(this MovieResource resource, Core.Tv.Movie m
|
|||
|
||||
movie.RootFolderPath = resource.RootFolderPath;
|
||||
movie.Tags = resource.Tags;
|
||||
movie.AddOptions = resource.AddOptions;
|
||||
|
||||
return movie;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,8 @@ protected override void MainDbUpgrade()
|
|||
.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")
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -40,11 +40,16 @@ public Movie()
|
|||
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; }
|
||||
}
|
||||
}
|
57
src/NzbDrone.Core/Tv/MovieScannedHandler.cs
Normal file
57
src/NzbDrone.Core/Tv/MovieScannedHandler.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ public interface IMovieService
|
|||
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 @@ public bool MoviePathExists(string folder)
|
|||
return _movieRepository.MoviePathExists(folder);
|
||||
}
|
||||
|
||||
public void RemoveAddOptions(Movie movie)
|
||||
{
|
||||
_movieRepository.SetFields(movie, s => s.AddOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue