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