mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-16 21:15:33 -04:00
New: Alternative titles on Series Details UI
This commit is contained in:
@@ -5,7 +5,8 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
public class SceneMapping : ModelBase
|
||||
{
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
public string ParseTerm { get; set; }
|
||||
|
||||
[JsonProperty("searchTitle")]
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
public interface ISceneMappingRepository : IBasicRepository<SceneMapping>
|
||||
{
|
||||
|
||||
List<SceneMapping> FindByTvdbid(int tvdbId);
|
||||
}
|
||||
|
||||
public class SceneMappingRepository : BasicRepository<SceneMapping>, ISceneMappingRepository
|
||||
@@ -16,5 +17,9 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
}
|
||||
|
||||
public List<SceneMapping> FindByTvdbid(int tvdbId)
|
||||
{
|
||||
return Query.Where(x => x.TvdbId == tvdbId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
@@ -13,6 +14,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
string GetSceneName(int tvdbId);
|
||||
Nullable<int> GetTvDbId(string cleanName);
|
||||
List<SceneMapping> FindByTvdbid(int tvdbId);
|
||||
}
|
||||
|
||||
public class SceneMappingService : ISceneMappingService,
|
||||
@@ -24,6 +26,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
private readonly Logger _logger;
|
||||
private readonly ICached<SceneMapping> _getSceneNameCache;
|
||||
private readonly ICached<SceneMapping> _gettvdbIdCache;
|
||||
private readonly ICached<List<SceneMapping>> _findbytvdbIdCache;
|
||||
|
||||
public SceneMappingService(ISceneMappingRepository repository, ISceneMappingProxy sceneMappingProxy, ICacheManager cacheManager, Logger logger)
|
||||
{
|
||||
@@ -32,6 +35,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
|
||||
_getSceneNameCache = cacheManager.GetCache<SceneMapping>(GetType(), "scene_name");
|
||||
_gettvdbIdCache = cacheManager.GetCache<SceneMapping>(GetType(), "tvdb_id");
|
||||
_findbytvdbIdCache = cacheManager.GetCache<List<SceneMapping>>(GetType(), "find_tvdb_id");
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -54,6 +58,11 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
return mapping.TvdbId;
|
||||
}
|
||||
|
||||
public List<SceneMapping> FindByTvdbid(int tvdbId)
|
||||
{
|
||||
return _findbytvdbIdCache.Find(tvdbId.ToString());
|
||||
}
|
||||
|
||||
private void UpdateMappings()
|
||||
{
|
||||
_logger.Info("Updating Scene mapping");
|
||||
@@ -68,7 +77,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
|
||||
foreach (var sceneMapping in mappings)
|
||||
{
|
||||
sceneMapping.ParseTerm = sceneMapping.ParseTerm.CleanSeriesTitle();
|
||||
sceneMapping.ParseTerm = sceneMapping.Title.CleanSeriesTitle();
|
||||
}
|
||||
|
||||
_repository.InsertMany(mappings);
|
||||
@@ -92,12 +101,17 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
|
||||
_gettvdbIdCache.Clear();
|
||||
_getSceneNameCache.Clear();
|
||||
_findbytvdbIdCache.Clear();
|
||||
|
||||
foreach (var sceneMapping in mappings)
|
||||
{
|
||||
_getSceneNameCache.Set(sceneMapping.TvdbId.ToString(), sceneMapping);
|
||||
_gettvdbIdCache.Set(sceneMapping.ParseTerm.CleanSeriesTitle(), sceneMapping);
|
||||
}
|
||||
foreach (var sceneMapping in mappings.GroupBy(x => x.TvdbId))
|
||||
{
|
||||
_findbytvdbIdCache.Set(sceneMapping.Key.ToString(), sceneMapping.ToList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user