|
|
@ -27,6 +27,8 @@ namespace NzbDrone.Core.Tv
|
|
|
|
Series FindByTvdbId(int tvdbId);
|
|
|
|
Series FindByTvdbId(int tvdbId);
|
|
|
|
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
|
|
|
|
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
|
|
|
|
void DeleteSeries(int seriesId, bool deleteFiles);
|
|
|
|
void DeleteSeries(int seriesId, bool deleteFiles);
|
|
|
|
|
|
|
|
List<Series> GetAllSeries();
|
|
|
|
|
|
|
|
void UpdateSeries(Series series);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SeriesService : ISeriesService, IHandleAsync<SeriesAddedEvent>
|
|
|
|
public class SeriesService : ISeriesService, IHandleAsync<SeriesAddedEvent>
|
|
|
@ -35,19 +37,19 @@ namespace NzbDrone.Core.Tv
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly IConfigService _configService;
|
|
|
|
private readonly IProvideSeriesInfo _seriesInfoProxy;
|
|
|
|
private readonly IProvideSeriesInfo _seriesInfoProxy;
|
|
|
|
private readonly IEventAggregator _eventAggregator;
|
|
|
|
private readonly IEventAggregator _eventAggregator;
|
|
|
|
private readonly IBasicRepository<RootFolder> _rootFolderRepository;
|
|
|
|
private readonly IRootFolderService _rootFolderService;
|
|
|
|
private readonly DiskProvider _diskProvider;
|
|
|
|
private readonly DiskProvider _diskProvider;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService,
|
|
|
|
public SeriesService(ISeriesRepository seriesRepository, IConfigService configServiceService,
|
|
|
|
IProvideSeriesInfo seriesInfoProxy, IEventAggregator eventAggregator,
|
|
|
|
IProvideSeriesInfo seriesInfoProxy, IEventAggregator eventAggregator,
|
|
|
|
IBasicRepository<RootFolder> rootFolderRepository, DiskProvider diskProvider, Logger logger)
|
|
|
|
IRootFolderService rootFolderService, DiskProvider diskProvider, Logger logger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_seriesRepository = seriesRepository;
|
|
|
|
_seriesRepository = seriesRepository;
|
|
|
|
_configService = configServiceService;
|
|
|
|
_configService = configServiceService;
|
|
|
|
_seriesInfoProxy = seriesInfoProxy;
|
|
|
|
_seriesInfoProxy = seriesInfoProxy;
|
|
|
|
_eventAggregator = eventAggregator;
|
|
|
|
_eventAggregator = eventAggregator;
|
|
|
|
_rootFolderRepository = rootFolderRepository;
|
|
|
|
_rootFolderService = rootFolderService;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,7 +96,7 @@ namespace NzbDrone.Core.Tv
|
|
|
|
if(String.IsNullOrWhiteSpace(newSeries.FolderName))
|
|
|
|
if(String.IsNullOrWhiteSpace(newSeries.FolderName))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title);
|
|
|
|
newSeries.FolderName = FileNameBuilder.CleanFilename(newSeries.Title);
|
|
|
|
_diskProvider.CreateDirectory(Path.Combine(_rootFolderRepository.Get(newSeries.RootFolderId).Path, newSeries.FolderName));
|
|
|
|
_diskProvider.CreateDirectory(Path.Combine(_rootFolderService.Get(newSeries.RootFolderId).Path, newSeries.FolderName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path);
|
|
|
|
_logger.Info("Adding Series [{0}] Path: [{1}]", newSeries.Title, newSeries.Path);
|
|
|
@ -153,6 +155,16 @@ namespace NzbDrone.Core.Tv
|
|
|
|
_eventAggregator.Publish(new SeriesDeletedEvent(series, deleteFiles));
|
|
|
|
_eventAggregator.Publish(new SeriesDeletedEvent(series, deleteFiles));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Series> GetAllSeries()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _seriesRepository.All().ToList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateSeries(Series series)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_seriesRepository.Update(series);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void HandleAsync(SeriesAddedEvent message)
|
|
|
|
public void HandleAsync(SeriesAddedEvent message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UpdateSeriesInfo(message.Series.Id);
|
|
|
|
UpdateSeriesInfo(message.Series.Id);
|
|
|
|