mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 04:59:35 -07:00
Remove ISceneMappingService to get rid of service.sonarr.tv access errors
This commit is contained in:
parent
c6f696a090
commit
1a11a932e3
7 changed files with 263 additions and 270 deletions
|
@ -31,14 +31,14 @@ namespace NzbDrone.Api.Series
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly ISeriesService _seriesService;
|
||||||
private readonly IAddSeriesService _addSeriesService;
|
private readonly IAddSeriesService _addSeriesService;
|
||||||
private readonly ISeriesStatisticsService _seriesStatisticsService;
|
private readonly ISeriesStatisticsService _seriesStatisticsService;
|
||||||
private readonly ISceneMappingService _sceneMappingService;
|
// private readonly ISceneMappingService _sceneMappingService;
|
||||||
private readonly IMapCoversToLocal _coverMapper;
|
private readonly IMapCoversToLocal _coverMapper;
|
||||||
|
|
||||||
public SeriesModule(IBroadcastSignalRMessage signalRBroadcaster,
|
public SeriesModule(IBroadcastSignalRMessage signalRBroadcaster,
|
||||||
ISeriesService seriesService,
|
ISeriesService seriesService,
|
||||||
IAddSeriesService addSeriesService,
|
IAddSeriesService addSeriesService,
|
||||||
ISeriesStatisticsService seriesStatisticsService,
|
ISeriesStatisticsService seriesStatisticsService,
|
||||||
ISceneMappingService sceneMappingService,
|
// ISceneMappingService sceneMappingService,
|
||||||
IMapCoversToLocal coverMapper,
|
IMapCoversToLocal coverMapper,
|
||||||
RootFolderValidator rootFolderValidator,
|
RootFolderValidator rootFolderValidator,
|
||||||
SeriesPathValidator seriesPathValidator,
|
SeriesPathValidator seriesPathValidator,
|
||||||
|
@ -52,7 +52,7 @@ namespace NzbDrone.Api.Series
|
||||||
_seriesService = seriesService;
|
_seriesService = seriesService;
|
||||||
_addSeriesService = addSeriesService;
|
_addSeriesService = addSeriesService;
|
||||||
_seriesStatisticsService = seriesStatisticsService;
|
_seriesStatisticsService = seriesStatisticsService;
|
||||||
_sceneMappingService = sceneMappingService;
|
// _sceneMappingService = sceneMappingService;
|
||||||
|
|
||||||
_coverMapper = coverMapper;
|
_coverMapper = coverMapper;
|
||||||
|
|
||||||
|
@ -197,11 +197,11 @@ namespace NzbDrone.Api.Series
|
||||||
|
|
||||||
private void PopulateAlternateTitles(SeriesResource resource)
|
private void PopulateAlternateTitles(SeriesResource resource)
|
||||||
{
|
{
|
||||||
var mappings = _sceneMappingService.FindByTvdbId(resource.TvdbId);
|
//var mappings = null //_sceneMappingService.FindByTvdbId(resource.TvdbId);
|
||||||
|
|
||||||
if (mappings == null) return;
|
//if (mappings == null) return;
|
||||||
|
return;
|
||||||
resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList();
|
// resource.AlternateTitles = mappings.Select(v => new AlternateTitleResource { Title = v.Title, SeasonNumber = v.SeasonNumber, SceneSeasonNumber = v.SceneSeasonNumber }).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(EpisodeImportedEvent message)
|
public void Handle(EpisodeImportedEvent message)
|
||||||
|
|
|
@ -77,10 +77,6 @@
|
||||||
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
|
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="NCrunch.Framework, Version=3.2.0.3, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\NCrunch.Framework.3.2.0.3\lib\NCrunch.Framework.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
|
|
@ -11,243 +11,243 @@ using NzbDrone.Core.Tv.Events;
|
||||||
|
|
||||||
namespace NzbDrone.Core.DataAugmentation.Scene
|
namespace NzbDrone.Core.DataAugmentation.Scene
|
||||||
{
|
{
|
||||||
public interface ISceneMappingService
|
//public interface ISceneMappingService
|
||||||
{
|
//{
|
||||||
List<string> GetSceneNames(int tvdbId, List<int> seasonNumbers, List<int> sceneSeasonNumbers);
|
// List<string> GetSceneNames(int tvdbId, List<int> seasonNumbers, List<int> sceneSeasonNumbers);
|
||||||
int? FindTvdbId(string title);
|
// int? FindTvdbId(string title);
|
||||||
List<SceneMapping> FindByTvdbId(int tvdbId);
|
// List<SceneMapping> FindByTvdbId(int tvdbId);
|
||||||
SceneMapping FindSceneMapping(string title);
|
// SceneMapping FindSceneMapping(string title);
|
||||||
int? GetSceneSeasonNumber(string title);
|
// int? GetSceneSeasonNumber(string title);
|
||||||
int? GetTvdbSeasonNumber(string title);
|
// int? GetTvdbSeasonNumber(string title);
|
||||||
int? GetSceneSeasonNumber(int tvdbId, int seasonNumber);
|
// int? GetSceneSeasonNumber(int tvdbId, int seasonNumber);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public class SceneMappingService : ISceneMappingService,
|
//public class SceneMappingService : ISceneMappingService,
|
||||||
IHandle<SeriesRefreshStartingEvent>,
|
// IHandle<SeriesRefreshStartingEvent>,
|
||||||
IExecute<UpdateSceneMappingCommand>
|
// IExecute<UpdateSceneMappingCommand>
|
||||||
{
|
//{
|
||||||
private readonly ISceneMappingRepository _repository;
|
// private readonly ISceneMappingRepository _repository;
|
||||||
private readonly IEnumerable<ISceneMappingProvider> _sceneMappingProviders;
|
// private readonly IEnumerable<ISceneMappingProvider> _sceneMappingProviders;
|
||||||
private readonly IEventAggregator _eventAggregator;
|
// private readonly IEventAggregator _eventAggregator;
|
||||||
private readonly Logger _logger;
|
// private readonly Logger _logger;
|
||||||
private readonly ICachedDictionary<List<SceneMapping>> _getTvdbIdCache;
|
// private readonly ICachedDictionary<List<SceneMapping>> _getTvdbIdCache;
|
||||||
private readonly ICachedDictionary<List<SceneMapping>> _findByTvdbIdCache;
|
// private readonly ICachedDictionary<List<SceneMapping>> _findByTvdbIdCache;
|
||||||
|
|
||||||
public SceneMappingService(ISceneMappingRepository repository,
|
//public SceneMappingService(ISceneMappingRepository repository,
|
||||||
ICacheManager cacheManager,
|
// ICacheManager cacheManager,
|
||||||
IEnumerable<ISceneMappingProvider> sceneMappingProviders,
|
// IEnumerable<ISceneMappingProvider> sceneMappingProviders,
|
||||||
IEventAggregator eventAggregator,
|
// IEventAggregator eventAggregator,
|
||||||
Logger logger)
|
// Logger logger)
|
||||||
{
|
//{
|
||||||
_repository = repository;
|
// _repository = repository;
|
||||||
_sceneMappingProviders = sceneMappingProviders;
|
// _sceneMappingProviders = sceneMappingProviders;
|
||||||
_eventAggregator = eventAggregator;
|
// _eventAggregator = eventAggregator;
|
||||||
_logger = logger;
|
// _logger = logger;
|
||||||
|
|
||||||
_getTvdbIdCache = cacheManager.GetCacheDictionary<List<SceneMapping>>(GetType(), "tvdb_id");
|
// _getTvdbIdCache = cacheManager.GetCacheDictionary<List<SceneMapping>>(GetType(), "tvdb_id");
|
||||||
_findByTvdbIdCache = cacheManager.GetCacheDictionary<List<SceneMapping>>(GetType(), "find_tvdb_id");
|
// _findByTvdbIdCache = cacheManager.GetCacheDictionary<List<SceneMapping>>(GetType(), "find_tvdb_id");
|
||||||
}
|
//}
|
||||||
|
|
||||||
public List<string> GetSceneNames(int tvdbId, List<int> seasonNumbers, List<int> sceneSeasonNumbers)
|
// public List<string> GetSceneNames(int tvdbId, List<int> seasonNumbers, List<int> sceneSeasonNumbers)
|
||||||
{
|
// {
|
||||||
var mappings = FindByTvdbId(tvdbId);
|
// var mappings = FindByTvdbId(tvdbId);
|
||||||
|
|
||||||
if (mappings == null)
|
// if (mappings == null)
|
||||||
{
|
// {
|
||||||
return new List<string>();
|
// return new List<string>();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var names = mappings.Where(n => n.SeasonNumber.HasValue && seasonNumbers.Contains(n.SeasonNumber.Value) ||
|
// var names = mappings.Where(n => n.SeasonNumber.HasValue && seasonNumbers.Contains(n.SeasonNumber.Value) ||
|
||||||
n.SceneSeasonNumber.HasValue && sceneSeasonNumbers.Contains(n.SceneSeasonNumber.Value) ||
|
// n.SceneSeasonNumber.HasValue && sceneSeasonNumbers.Contains(n.SceneSeasonNumber.Value) ||
|
||||||
(n.SeasonNumber ?? -1) == -1 && (n.SceneSeasonNumber ?? -1) == -1)
|
// (n.SeasonNumber ?? -1) == -1 && (n.SceneSeasonNumber ?? -1) == -1)
|
||||||
.Select(n => n.SearchTerm).Distinct().ToList();
|
// .Select(n => n.SearchTerm).Distinct().ToList();
|
||||||
|
|
||||||
return FilterNonEnglish(names);
|
// return FilterNonEnglish(names);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public int? FindTvdbId(string title)
|
// public int? FindTvdbId(string title)
|
||||||
{
|
// {
|
||||||
var mapping = FindMapping(title);
|
// var mapping = FindMapping(title);
|
||||||
|
|
||||||
if (mapping == null)
|
// if (mapping == null)
|
||||||
return null;
|
// return null;
|
||||||
|
|
||||||
return mapping.TvdbId;
|
// return mapping.TvdbId;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public List<SceneMapping> FindByTvdbId(int tvdbId)
|
// public List<SceneMapping> FindByTvdbId(int tvdbId)
|
||||||
{
|
// {
|
||||||
if (_findByTvdbIdCache.Count == 0)
|
// if (_findByTvdbIdCache.Count == 0)
|
||||||
{
|
// {
|
||||||
RefreshCache();
|
// RefreshCache();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var mappings = _findByTvdbIdCache.Find(tvdbId.ToString());
|
// var mappings = _findByTvdbIdCache.Find(tvdbId.ToString());
|
||||||
|
|
||||||
if (mappings == null)
|
// if (mappings == null)
|
||||||
{
|
// {
|
||||||
return new List<SceneMapping>();
|
// return new List<SceneMapping>();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return mappings;
|
// return mappings;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public SceneMapping FindSceneMapping(string title)
|
// public SceneMapping FindSceneMapping(string title)
|
||||||
{
|
// {
|
||||||
return FindMapping(title);
|
// return FindMapping(title);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public int? GetSceneSeasonNumber(string title)
|
// public int? GetSceneSeasonNumber(string title)
|
||||||
{
|
// {
|
||||||
var mapping = FindMapping(title);
|
// var mapping = FindMapping(title);
|
||||||
|
|
||||||
if (mapping == null)
|
// if (mapping == null)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return mapping.SceneSeasonNumber;
|
// return mapping.SceneSeasonNumber;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public int? GetTvdbSeasonNumber(string title)
|
// public int? GetTvdbSeasonNumber(string title)
|
||||||
{
|
// {
|
||||||
var mapping = FindMapping(title);
|
// var mapping = FindMapping(title);
|
||||||
|
|
||||||
if (mapping == null)
|
// if (mapping == null)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return mapping.SeasonNumber;
|
// return mapping.SeasonNumber;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public int? GetSceneSeasonNumber(int tvdbId, int seasonNumber)
|
// public int? GetSceneSeasonNumber(int tvdbId, int seasonNumber)
|
||||||
{
|
// {
|
||||||
var mappings = FindByTvdbId(tvdbId);
|
// var mappings = FindByTvdbId(tvdbId);
|
||||||
|
|
||||||
if (mappings == null)
|
// if (mappings == null)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var mapping = mappings.FirstOrDefault(e => e.SeasonNumber == seasonNumber && e.SceneSeasonNumber.HasValue);
|
// var mapping = mappings.FirstOrDefault(e => e.SeasonNumber == seasonNumber && e.SceneSeasonNumber.HasValue);
|
||||||
|
|
||||||
if (mapping == null)
|
// if (mapping == null)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return mapping.SceneSeasonNumber;
|
// return mapping.SceneSeasonNumber;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void UpdateMappings()
|
// private void UpdateMappings()
|
||||||
{
|
// {
|
||||||
_logger.Info("Updating Scene mappings");
|
// _logger.Info("Updating Scene mappings");
|
||||||
|
|
||||||
foreach (var sceneMappingProvider in _sceneMappingProviders)
|
// foreach (var sceneMappingProvider in _sceneMappingProviders)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var mappings = sceneMappingProvider.GetSceneMappings();
|
// var mappings = sceneMappingProvider.GetSceneMappings();
|
||||||
|
|
||||||
if (mappings.Any())
|
// if (mappings.Any())
|
||||||
{
|
// {
|
||||||
_repository.Clear(sceneMappingProvider.GetType().Name);
|
// _repository.Clear(sceneMappingProvider.GetType().Name);
|
||||||
|
|
||||||
mappings.RemoveAll(sceneMapping =>
|
// mappings.RemoveAll(sceneMapping =>
|
||||||
{
|
// {
|
||||||
if (sceneMapping.Title.IsNullOrWhiteSpace() ||
|
// if (sceneMapping.Title.IsNullOrWhiteSpace() ||
|
||||||
sceneMapping.SearchTerm.IsNullOrWhiteSpace())
|
// sceneMapping.SearchTerm.IsNullOrWhiteSpace())
|
||||||
{
|
// {
|
||||||
_logger.Warn("Invalid scene mapping found for: {0}, skipping", sceneMapping.TvdbId);
|
// _logger.Warn("Invalid scene mapping found for: {0}, skipping", sceneMapping.TvdbId);
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return false;
|
// return false;
|
||||||
});
|
// });
|
||||||
|
|
||||||
foreach (var sceneMapping in mappings)
|
// foreach (var sceneMapping in mappings)
|
||||||
{
|
// {
|
||||||
sceneMapping.ParseTerm = sceneMapping.Title.CleanSeriesTitle();
|
// sceneMapping.ParseTerm = sceneMapping.Title.CleanSeriesTitle();
|
||||||
sceneMapping.Type = sceneMappingProvider.GetType().Name;
|
// sceneMapping.Type = sceneMappingProvider.GetType().Name;
|
||||||
}
|
// }
|
||||||
|
|
||||||
_repository.InsertMany(mappings.ToList());
|
// _repository.InsertMany(mappings.ToList());
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
_logger.Warn("Received empty list of mapping. will not update.");
|
// _logger.Warn("Received empty list of mapping. will not update.");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
_logger.Error(ex, "Failed to Update Scene Mappings.");
|
// _logger.Error(ex, "Failed to Update Scene Mappings.");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
RefreshCache();
|
// RefreshCache();
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent());
|
// _eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent());
|
||||||
}
|
// }
|
||||||
|
|
||||||
private SceneMapping FindMapping(string title)
|
// private SceneMapping FindMapping(string title)
|
||||||
{
|
// {
|
||||||
if (_getTvdbIdCache.Count == 0)
|
// if (_getTvdbIdCache.Count == 0)
|
||||||
{
|
// {
|
||||||
RefreshCache();
|
// RefreshCache();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle());
|
// var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle());
|
||||||
|
|
||||||
if (candidates == null)
|
// if (candidates == null)
|
||||||
{
|
// {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (candidates.Count == 1)
|
// if (candidates.Count == 1)
|
||||||
{
|
// {
|
||||||
return candidates.First();
|
// return candidates.First();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber)
|
// var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber)
|
||||||
.FirstOrDefault(v => v.Title == title);
|
// .FirstOrDefault(v => v.Title == title);
|
||||||
|
|
||||||
if (exactMatch != null)
|
// if (exactMatch != null)
|
||||||
{
|
// {
|
||||||
return exactMatch;
|
// return exactMatch;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10))
|
// var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10))
|
||||||
.ThenByDescending(v => v.SeasonNumber)
|
// .ThenByDescending(v => v.SeasonNumber)
|
||||||
.First();
|
// .First();
|
||||||
|
|
||||||
return closestMatch;
|
// return closestMatch;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void RefreshCache()
|
// private void RefreshCache()
|
||||||
{
|
// {
|
||||||
var mappings = _repository.All().ToList();
|
// var mappings = _repository.All().ToList();
|
||||||
|
|
||||||
_getTvdbIdCache.Update(mappings.GroupBy(v => v.ParseTerm).ToDictionary(v => v.Key, v => v.ToList()));
|
// _getTvdbIdCache.Update(mappings.GroupBy(v => v.ParseTerm).ToDictionary(v => v.Key, v => v.ToList()));
|
||||||
_findByTvdbIdCache.Update(mappings.GroupBy(v => v.TvdbId).ToDictionary(v => v.Key.ToString(), v => v.ToList()));
|
// _findByTvdbIdCache.Update(mappings.GroupBy(v => v.TvdbId).ToDictionary(v => v.Key.ToString(), v => v.ToList()));
|
||||||
}
|
// }
|
||||||
|
|
||||||
private List<string> FilterNonEnglish(List<string> titles)
|
// private List<string> FilterNonEnglish(List<string> titles)
|
||||||
{
|
// {
|
||||||
return titles.Where(title => title.All(c => c <= 255)).ToList();
|
// return titles.Where(title => title.All(c => c <= 255)).ToList();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void Handle(SeriesRefreshStartingEvent message)
|
// public void Handle(SeriesRefreshStartingEvent message)
|
||||||
{
|
// {
|
||||||
if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1)))
|
// if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1)))
|
||||||
{
|
// {
|
||||||
UpdateMappings();
|
// UpdateMappings();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void Execute(UpdateSceneMappingCommand message)
|
// public void Execute(UpdateSceneMappingCommand message)
|
||||||
{
|
// {
|
||||||
UpdateMappings();
|
// UpdateMappings();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,21 +25,21 @@ namespace NzbDrone.Core.IndexerSearch
|
||||||
public class NzbSearchService : ISearchForNzb
|
public class NzbSearchService : ISearchForNzb
|
||||||
{
|
{
|
||||||
private readonly IIndexerFactory _indexerFactory;
|
private readonly IIndexerFactory _indexerFactory;
|
||||||
private readonly ISceneMappingService _sceneMapping;
|
// private readonly ISceneMappingService _sceneMapping;
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly ISeriesService _seriesService;
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
private readonly IMakeDownloadDecision _makeDownloadDecision;
|
private readonly IMakeDownloadDecision _makeDownloadDecision;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public NzbSearchService(IIndexerFactory indexerFactory,
|
public NzbSearchService(IIndexerFactory indexerFactory,
|
||||||
ISceneMappingService sceneMapping,
|
// ISceneMappingService sceneMapping,
|
||||||
ISeriesService seriesService,
|
ISeriesService seriesService,
|
||||||
IEpisodeService episodeService,
|
IEpisodeService episodeService,
|
||||||
IMakeDownloadDecision makeDownloadDecision,
|
IMakeDownloadDecision makeDownloadDecision,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_indexerFactory = indexerFactory;
|
_indexerFactory = indexerFactory;
|
||||||
_sceneMapping = sceneMapping;
|
//_sceneMapping = sceneMapping;
|
||||||
_seriesService = seriesService;
|
_seriesService = seriesService;
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_makeDownloadDecision = makeDownloadDecision;
|
_makeDownloadDecision = makeDownloadDecision;
|
||||||
|
@ -233,9 +233,9 @@ namespace NzbDrone.Core.IndexerSearch
|
||||||
var spec = new TSpec();
|
var spec = new TSpec();
|
||||||
|
|
||||||
spec.Series = series;
|
spec.Series = series;
|
||||||
spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId,
|
// spec.SceneTitles = _sceneMapping.GetSceneNames(series.TvdbId,
|
||||||
episodes.Select(e => e.SeasonNumber).Distinct().ToList(),
|
// episodes.Select(e => e.SeasonNumber).Distinct().ToList(),
|
||||||
episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList());
|
// episodes.Select(e => e.SceneSeasonNumber ?? e.SeasonNumber).Distinct().ToList());
|
||||||
|
|
||||||
spec.Episodes = episodes;
|
spec.Episodes = episodes;
|
||||||
|
|
||||||
|
|
|
@ -26,17 +26,17 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly ISeriesService _seriesService;
|
||||||
private readonly ISceneMappingService _sceneMappingService;
|
// private readonly ISceneMappingService _sceneMappingService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ParsingService(IEpisodeService episodeService,
|
public ParsingService(IEpisodeService episodeService,
|
||||||
ISeriesService seriesService,
|
ISeriesService seriesService,
|
||||||
ISceneMappingService sceneMappingService,
|
// ISceneMappingService sceneMappingService,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_seriesService = seriesService;
|
_seriesService = seriesService;
|
||||||
_sceneMappingService = sceneMappingService;
|
// _sceneMappingService = sceneMappingService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ namespace NzbDrone.Core.Parser
|
||||||
if (searchCriteria != null)
|
if (searchCriteria != null)
|
||||||
{
|
{
|
||||||
if (tvdbId == 0)
|
if (tvdbId == 0)
|
||||||
tvdbId = _sceneMappingService.FindTvdbId(title) ?? 0;
|
tvdbId = 0; // _sceneMappingService.FindTvdbId(title) ?? 0;
|
||||||
|
|
||||||
if (tvdbId != 0 && tvdbId == searchCriteria.Series.TvdbId)
|
if (tvdbId != 0 && tvdbId == searchCriteria.Series.TvdbId)
|
||||||
{
|
{
|
||||||
|
@ -252,24 +252,24 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
Series series = null;
|
Series series = null;
|
||||||
|
|
||||||
var sceneMappingTvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle);
|
//var sceneMappingTvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle);
|
||||||
if (sceneMappingTvdbId.HasValue)
|
//if (sceneMappingTvdbId.HasValue)
|
||||||
{
|
//{
|
||||||
if (searchCriteria != null && searchCriteria.Series.TvdbId == sceneMappingTvdbId.Value)
|
// if (searchCriteria != null && searchCriteria.Series.TvdbId == sceneMappingTvdbId.Value)
|
||||||
{
|
// {
|
||||||
return searchCriteria.Series;
|
// return searchCriteria.Series;
|
||||||
}
|
// }
|
||||||
|
|
||||||
series = _seriesService.FindByTvdbId(sceneMappingTvdbId.Value);
|
// series = _seriesService.FindByTvdbId(sceneMappingTvdbId.Value);
|
||||||
|
|
||||||
if (series == null)
|
// if (series == null)
|
||||||
{
|
// {
|
||||||
_logger.Debug("No matching series {0}", parsedEpisodeInfo.SeriesTitle);
|
// _logger.Debug("No matching series {0}", parsedEpisodeInfo.SeriesTitle);
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return series;
|
// return series;
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (searchCriteria != null)
|
if (searchCriteria != null)
|
||||||
{
|
{
|
||||||
|
@ -341,7 +341,7 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
var result = new List<Episode>();
|
var result = new List<Episode>();
|
||||||
|
|
||||||
var sceneSeasonNumber = _sceneMappingService.GetSceneSeasonNumber(parsedEpisodeInfo.SeriesTitle);
|
// var sceneSeasonNumber = _sceneMappingService.GetSceneSeasonNumber(parsedEpisodeInfo.SeriesTitle);
|
||||||
|
|
||||||
foreach (var absoluteEpisodeNumber in parsedEpisodeInfo.AbsoluteEpisodeNumbers)
|
foreach (var absoluteEpisodeNumber in parsedEpisodeInfo.AbsoluteEpisodeNumbers)
|
||||||
{
|
{
|
||||||
|
@ -352,31 +352,31 @@ namespace NzbDrone.Core.Parser
|
||||||
episode = _episodeService.FindEpisode(series.Id, 0, absoluteEpisodeNumber);
|
episode = _episodeService.FindEpisode(series.Id, 0, absoluteEpisodeNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (sceneSource)
|
//else if (sceneSource)
|
||||||
{
|
//{
|
||||||
// Is there a reason why we excluded season 1 from this handling before?
|
// // Is there a reason why we excluded season 1 from this handling before?
|
||||||
// Might have something to do with the scene name to season number check
|
// // Might have something to do with the scene name to season number check
|
||||||
// If this needs to be reverted tests will need to be added
|
// // If this needs to be reverted tests will need to be added
|
||||||
if (sceneSeasonNumber.HasValue)
|
// if (sceneSeasonNumber.HasValue)
|
||||||
{
|
// {
|
||||||
var episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
// var episodes = _episodeService.FindEpisodesBySceneNumbering(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
||||||
|
|
||||||
if (episodes.Count == 1)
|
// if (episodes.Count == 1)
|
||||||
{
|
// {
|
||||||
episode = episodes.First();
|
// episode = episodes.First();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (episode == null)
|
// if (episode == null)
|
||||||
{
|
// {
|
||||||
episode = _episodeService.FindEpisode(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
// episode = _episodeService.FindEpisode(series.Id, sceneSeasonNumber.Value, absoluteEpisodeNumber);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
episode = _episodeService.FindEpisodeBySceneNumbering(series.Id, absoluteEpisodeNumber);
|
// episode = _episodeService.FindEpisodeBySceneNumbering(series.Id, absoluteEpisodeNumber);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (episode == null)
|
if (episode == null)
|
||||||
{
|
{
|
||||||
|
@ -403,16 +403,16 @@ namespace NzbDrone.Core.Parser
|
||||||
var result = new List<Episode>();
|
var result = new List<Episode>();
|
||||||
var seasonNumber = parsedEpisodeInfo.SeasonNumber;
|
var seasonNumber = parsedEpisodeInfo.SeasonNumber;
|
||||||
|
|
||||||
if (sceneSource)
|
//if (sceneSource)
|
||||||
{
|
//{
|
||||||
var sceneMapping = _sceneMappingService.FindSceneMapping(parsedEpisodeInfo.SeriesTitle);
|
// var sceneMapping = _sceneMappingService.FindSceneMapping(parsedEpisodeInfo.SeriesTitle);
|
||||||
|
|
||||||
if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 &&
|
// if (sceneMapping != null && sceneMapping.SeasonNumber.HasValue && sceneMapping.SeasonNumber.Value >= 0 &&
|
||||||
sceneMapping.SceneSeasonNumber == seasonNumber)
|
// sceneMapping.SceneSeasonNumber == seasonNumber)
|
||||||
{
|
// {
|
||||||
seasonNumber = sceneMapping.SeasonNumber.Value;
|
// seasonNumber = sceneMapping.SeasonNumber.Value;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (parsedEpisodeInfo.EpisodeNumbers == null)
|
if (parsedEpisodeInfo.EpisodeNumbers == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,21 +35,21 @@ namespace NzbDrone.Core.Tv
|
||||||
{
|
{
|
||||||
private readonly ISeriesRepository _seriesRepository;
|
private readonly ISeriesRepository _seriesRepository;
|
||||||
private readonly IEventAggregator _eventAggregator;
|
private readonly IEventAggregator _eventAggregator;
|
||||||
private readonly ISceneMappingService _sceneMappingService;
|
// private readonly ISceneMappingService _sceneMappingService;
|
||||||
private readonly IEpisodeService _episodeService;
|
private readonly IEpisodeService _episodeService;
|
||||||
private readonly IBuildFileNames _fileNameBuilder;
|
private readonly IBuildFileNames _fileNameBuilder;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public SeriesService(ISeriesRepository seriesRepository,
|
public SeriesService(ISeriesRepository seriesRepository,
|
||||||
IEventAggregator eventAggregator,
|
IEventAggregator eventAggregator,
|
||||||
ISceneMappingService sceneMappingService,
|
// ISceneMappingService sceneMappingService,
|
||||||
IEpisodeService episodeService,
|
IEpisodeService episodeService,
|
||||||
IBuildFileNames fileNameBuilder,
|
IBuildFileNames fileNameBuilder,
|
||||||
Logger logger)
|
Logger logger)
|
||||||
{
|
{
|
||||||
_seriesRepository = seriesRepository;
|
_seriesRepository = seriesRepository;
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
_sceneMappingService = sceneMappingService;
|
//_sceneMappingService = sceneMappingService;
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_fileNameBuilder = fileNameBuilder;
|
_fileNameBuilder = fileNameBuilder;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
@ -85,12 +85,12 @@ namespace NzbDrone.Core.Tv
|
||||||
|
|
||||||
public Series FindByTitle(string title)
|
public Series FindByTitle(string title)
|
||||||
{
|
{
|
||||||
var tvdbId = _sceneMappingService.FindTvdbId(title);
|
//var tvdbId = _sceneMappingService.FindTvdbId(title);
|
||||||
|
|
||||||
if (tvdbId.HasValue)
|
//if (tvdbId.HasValue)
|
||||||
{
|
//{
|
||||||
return _seriesRepository.FindByTvdbId(tvdbId.Value);
|
// return _seriesRepository.FindByTvdbId(tvdbId.Value);
|
||||||
}
|
//}
|
||||||
|
|
||||||
return _seriesRepository.FindByTitle(title.CleanSeriesTitle());
|
return _seriesRepository.FindByTitle(title.CleanSeriesTitle());
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,6 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="Microsoft.Practices.ServiceLocation">
|
|
||||||
<HintPath>..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.Practices.Unity">
|
<Reference Include="Microsoft.Practices.Unity">
|
||||||
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
|
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue