mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
removed sqlce
This commit is contained in:
parent
b76c6329fe
commit
beb2f7c7fd
105 changed files with 410 additions and 5340 deletions
73
NzbDrone.Core/ReferenceData/SceneMappingProvider.cs
Normal file
73
NzbDrone.Core/ReferenceData/SceneMappingProvider.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public class SceneMappingService : IInitializable
|
||||
{
|
||||
private readonly ISceneMappingRepository _repository;
|
||||
private readonly ISceneMappingProxy _sceneMappingProxy;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public SceneMappingService(ISceneMappingRepository repository, ISceneMappingProxy sceneMappingProxy, Logger logger)
|
||||
{
|
||||
_repository = repository;
|
||||
_sceneMappingProxy = sceneMappingProxy;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void UpdateMappings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var mappings = _sceneMappingProxy.Fetch();
|
||||
|
||||
_repository.Purge();
|
||||
_repository.InsertMany(mappings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.InfoException("Failed to Update Scene Mappings:", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetSceneName(int tvdbId, int seasonNumber = -1)
|
||||
{
|
||||
var mapping = _repository.FindByTvdbId(tvdbId);
|
||||
|
||||
if(mapping == null) return null;
|
||||
|
||||
return mapping.SceneName;
|
||||
}
|
||||
|
||||
public virtual Nullable<Int32> GetTvDbId(string cleanName)
|
||||
{
|
||||
var mapping = _repository.FindByCleanTitle(cleanName);
|
||||
|
||||
if (mapping == null)
|
||||
return null;
|
||||
|
||||
return mapping.TvdbId;
|
||||
}
|
||||
|
||||
|
||||
public virtual string GetCleanName(int tvdbId)
|
||||
{
|
||||
var mapping = _repository.FindByTvdbId(tvdbId);
|
||||
|
||||
if (mapping == null) return null;
|
||||
|
||||
return mapping.CleanTitle;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (!_repository.HasItems())
|
||||
{
|
||||
UpdateMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue