|
|
@ -1,31 +1,22 @@
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common.EnsureThat;
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Organizer;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.Movies.Events;
|
|
|
|
using NzbDrone.Core.Movies.Events;
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
|
|
|
|
using NzbDrone.Core.MediaFiles.Events;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Movies.AlternativeTitles
|
|
|
|
namespace NzbDrone.Core.Movies.AlternativeTitles
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public interface IAlternativeTitleService
|
|
|
|
public interface IAlternativeTitleService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<AlternativeTitle> GetAllTitlesForMovie(Movie movie);
|
|
|
|
List<AlternativeTitle> GetAllTitlesForMovie(int movieId);
|
|
|
|
AlternativeTitle AddAltTitle(AlternativeTitle title, Movie movie);
|
|
|
|
AlternativeTitle AddAltTitle(AlternativeTitle title, Movie movie);
|
|
|
|
List<AlternativeTitle> AddAltTitles(List<AlternativeTitle> titles, Movie movie);
|
|
|
|
List<AlternativeTitle> AddAltTitles(List<AlternativeTitle> titles, Movie movie);
|
|
|
|
AlternativeTitle GetById(int id);
|
|
|
|
AlternativeTitle GetById(int id);
|
|
|
|
void DeleteNotEnoughVotes(List<AlternativeTitle> mappingsTitles);
|
|
|
|
void DeleteNotEnoughVotes(List<AlternativeTitle> mappingsTitles);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class AlternativeTitleService : IAlternativeTitleService
|
|
|
|
public class AlternativeTitleService : IAlternativeTitleService, IHandleAsync<MovieDeletedEvent>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IAlternativeTitleRepository _titleRepo;
|
|
|
|
private readonly IAlternativeTitleRepository _titleRepo;
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly IConfigService _configService;
|
|
|
@ -44,9 +35,9 @@ namespace NzbDrone.Core.Movies.AlternativeTitles
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<AlternativeTitle> GetAllTitlesForMovie(Movie movie)
|
|
|
|
public List<AlternativeTitle> GetAllTitlesForMovie(int movieId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _titleRepo.All().ToList();
|
|
|
|
return _titleRepo.FindByMovieId(movieId).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public AlternativeTitle AddAltTitle(AlternativeTitle title, Movie movie)
|
|
|
|
public AlternativeTitle AddAltTitle(AlternativeTitle title, Movie movie)
|
|
|
@ -78,5 +69,12 @@ namespace NzbDrone.Core.Movies.AlternativeTitles
|
|
|
|
var realT = _titleRepo.FindBySourceIds(toRemove.Select(t => t.SourceId).ToList());
|
|
|
|
var realT = _titleRepo.FindBySourceIds(toRemove.Select(t => t.SourceId).ToList());
|
|
|
|
_titleRepo.DeleteMany(realT);
|
|
|
|
_titleRepo.DeleteMany(realT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void HandleAsync(MovieDeletedEvent message)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var title = GetAllTitlesForMovie(message.Movie.Id);
|
|
|
|
|
|
|
|
_titleRepo.DeleteMany(title);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|