mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-15 09:33:52 -07:00
Added Music models and basic database
This commit is contained in:
parent
80e8ef4c7a
commit
9ce71ff698
10 changed files with 510 additions and 192 deletions
|
@ -9,6 +9,7 @@ using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.DataAugmentation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.DataAugmentation.Scene
|
namespace NzbDrone.Core.Test.DataAugmentation.Scene
|
||||||
{
|
{
|
||||||
|
|
|
@ -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();
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
75
src/NzbDrone.Core/Datastore/Migration/111_setup_music.cs
Normal file
75
src/NzbDrone.Core/Datastore/Migration/111_setup_music.cs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(111)]
|
||||||
|
public class setup_music : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Create.TableForModel("Artists")
|
||||||
|
.WithColumn("ItunesId").AsInt32().Unique()
|
||||||
|
.WithColumn("ArtistName").AsString().Unique()
|
||||||
|
.WithColumn("ArtistSlug").AsString().Unique()
|
||||||
|
.WithColumn("CleanTitle").AsString()
|
||||||
|
.WithColumn("Monitored").AsBoolean()
|
||||||
|
.WithColumn("LastInfoSync").AsDateTime().Nullable()
|
||||||
|
.WithColumn("LastDiskSync").AsDateTime().Nullable()
|
||||||
|
.WithColumn("Overview").AsString()
|
||||||
|
.WithColumn("Status").AsInt32()
|
||||||
|
.WithColumn("Path").AsString()
|
||||||
|
.WithColumn("Images").AsString()
|
||||||
|
.WithColumn("QualityProfileId").AsInt32()
|
||||||
|
.WithColumn("AirTime").AsString().Nullable() // JVM: This might be DropDate instead
|
||||||
|
//.WithColumn("BacklogSetting").AsInt32()
|
||||||
|
;
|
||||||
|
|
||||||
|
Create.TableForModel("Albums")
|
||||||
|
.WithColumn("AlbumId").AsInt32() // Does this map to collectionId?
|
||||||
|
.WithColumn("CompilationId").AsInt32()
|
||||||
|
.WithColumn("Compilation").AsBoolean()
|
||||||
|
.WithColumn("Title").AsString()
|
||||||
|
.WithColumn("Year").AsInt32()
|
||||||
|
.WithColumn("Image").AsInt32() // Is this needed?
|
||||||
|
.WithColumn("TrackCount").AsInt32()
|
||||||
|
.WithColumn("DiscCount").AsInt32()
|
||||||
|
.WithColumn("Monitored").AsBoolean();
|
||||||
|
|
||||||
|
Create.TableForModel("Tracks")
|
||||||
|
.WithColumn("ItunesTrackId").AsInt32().Unique()
|
||||||
|
.WithColumn("AlbumId").AsInt32()
|
||||||
|
.WithColumn("CompilationId").AsInt32().Nullable()
|
||||||
|
.WithColumn("Compilation").AsBoolean().WithDefaultValue("False")
|
||||||
|
.WithColumn("TrackNumber").AsInt32()
|
||||||
|
.WithColumn("Title").AsString().Nullable()
|
||||||
|
.WithColumn("Ignored").AsBoolean().Nullable()
|
||||||
|
.WithColumn("Explict").AsBoolean()
|
||||||
|
.WithColumn("TrackExplicitName").AsString().Nullable()
|
||||||
|
.WithColumn("TrackCensoredName").AsString().Nullable()
|
||||||
|
.WithColumn("TrackFileId").AsInt32().Nullable()
|
||||||
|
.WithColumn("ReleaseDate").AsDateTime().Nullable();
|
||||||
|
//.WithColumn("AbsoluteEpisodeNumber").AsInt32().Nullable()
|
||||||
|
//.WithColumn("SceneAbsoluteEpisodeNumber").AsInt32().Nullable()
|
||||||
|
//.WithColumn("SceneSeasonNumber").AsInt32().Nullable()
|
||||||
|
//.WithColumn("SceneEpisodeNumber").AsInt32().Nullable();
|
||||||
|
|
||||||
|
Create.TableForModel("TrackFiles")
|
||||||
|
.WithColumn("ArtistId").AsInt32()
|
||||||
|
.WithColumn("Path").AsString().Unique()
|
||||||
|
.WithColumn("Quality").AsString()
|
||||||
|
.WithColumn("Size").AsInt64()
|
||||||
|
.WithColumn("DateAdded").AsDateTime()
|
||||||
|
.WithColumn("AlbumId").AsInt32(); // How does this impact stand alone tracks?
|
||||||
|
|
||||||
|
Create.TableForModel("Compilation")
|
||||||
|
.WithColumn("CompilationId").AsInt32().Unique()
|
||||||
|
.WithColumn("ArtistId").AsString().Nullable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ using NzbDrone.Core.Extras.Metadata.Files;
|
||||||
using NzbDrone.Core.Extras.Others;
|
using NzbDrone.Core.Extras.Others;
|
||||||
using NzbDrone.Core.Extras.Subtitles;
|
using NzbDrone.Core.Extras.Subtitles;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Datastore
|
namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
|
@ -91,6 +92,29 @@ namespace NzbDrone.Core.Datastore
|
||||||
.Relationship()
|
.Relationship()
|
||||||
.HasOne(episode => episode.EpisodeFile, episode => episode.EpisodeFileId);
|
.HasOne(episode => episode.EpisodeFile, episode => episode.EpisodeFileId);
|
||||||
|
|
||||||
|
Mapper.Entity<Artist>().RegisterModel("Artist")
|
||||||
|
.Ignore(s => s.RootFolderPath)
|
||||||
|
.Relationship()
|
||||||
|
.HasOne(s => s.Profile, s => s.ProfileId);
|
||||||
|
|
||||||
|
Mapper.Entity<TrackFile>().RegisterModel("TrackFiles")
|
||||||
|
.Ignore(f => f.Path)
|
||||||
|
.Relationships.AutoMapICollectionOrComplexProperties()
|
||||||
|
.For("Tracks")
|
||||||
|
.LazyLoad(condition: parent => parent.Id > 0,
|
||||||
|
query: (db, parent) => db.Query<Track>().Where(c => c.ItunesTrackId == parent.Id).ToList())
|
||||||
|
.HasOne(file => file.Artist, file => file.AlbumId);
|
||||||
|
|
||||||
|
Mapper.Entity<Track>().RegisterModel("Tracks")
|
||||||
|
//.Ignore(e => e.SeriesTitle)
|
||||||
|
.Ignore(e => e.Album)
|
||||||
|
.Ignore(e => e.HasFile)
|
||||||
|
.Relationship()
|
||||||
|
.HasOne(track => track.TrackFile, track => track.TrackFileId);
|
||||||
|
|
||||||
|
Mapper.Entity<Compilation>().RegisterModel("Compilation")
|
||||||
|
.Relationships.AutoMapICollectionOrComplexProperties(); //TODO: Figure out how to map this Table
|
||||||
|
|
||||||
Mapper.Entity<QualityDefinition>().RegisterModel("QualityDefinitions")
|
Mapper.Entity<QualityDefinition>().RegisterModel("QualityDefinitions")
|
||||||
.Ignore(d => d.Weight);
|
.Ignore(d => d.Weight);
|
||||||
|
|
||||||
|
|
34
src/NzbDrone.Core/MediaFiles/TrackFile.cs
Normal file
34
src/NzbDrone.Core/MediaFiles/TrackFile.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using Marr.Data;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.MediaFiles
|
||||||
|
{
|
||||||
|
public class TrackFile : ModelBase
|
||||||
|
{
|
||||||
|
public int ItunesTrackId { get; set; }
|
||||||
|
public int AlbumId { get; set; }
|
||||||
|
public string RelativePath { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
public long Size { get; set; }
|
||||||
|
public DateTime DateAdded { get; set; }
|
||||||
|
public string SceneName { get; set; }
|
||||||
|
public string ReleaseGroup { get; set; }
|
||||||
|
public QualityModel Quality { get; set; }
|
||||||
|
public MediaInfoModel MediaInfo { get; set; }
|
||||||
|
public LazyLoaded<List<Track>> Episodes { get; set; }
|
||||||
|
public LazyLoaded<Artist> Artist { get; set; }
|
||||||
|
public LazyLoaded<List<Track>> Tracks { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("[{0}] {1}", Id, RelativePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
src/NzbDrone.Core/Music/Album.cs
Normal file
26
src/NzbDrone.Core/Music/Album.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Music
|
||||||
|
{
|
||||||
|
public class Album : IEmbeddedDocument
|
||||||
|
{
|
||||||
|
public Album()
|
||||||
|
{
|
||||||
|
Images = new List<MediaCover.MediaCover>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AlbumId { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public int Year { get; set; }
|
||||||
|
public int TrackCount { get; set; }
|
||||||
|
public int DiscCount { get; set; }
|
||||||
|
public bool Monitored { get; set; }
|
||||||
|
public List<MediaCover.MediaCover> Images { get; set; }
|
||||||
|
public List<Actor> Actors { get; set; } // These are band members. TODO: Refactor
|
||||||
|
}
|
||||||
|
}
|
83
src/NzbDrone.Core/Music/Artist.cs
Normal file
83
src/NzbDrone.Core/Music/Artist.cs
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
using Marr.Data;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Profiles;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Music
|
||||||
|
{
|
||||||
|
public class Artist : ModelBase
|
||||||
|
{
|
||||||
|
public Artist()
|
||||||
|
{
|
||||||
|
Images = new List<MediaCover.MediaCover>();
|
||||||
|
Genres = new List<string>();
|
||||||
|
//Members = new List<Person>(); // Artist Band Member? (NOTE: This should be per album)
|
||||||
|
Albums = new List<Album>();
|
||||||
|
Tags = new HashSet<int>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ItunesId { get; set; }
|
||||||
|
//public int TvRageId { get; set; }
|
||||||
|
//public int TvMazeId { get; set; }
|
||||||
|
//public string ImdbId { get; set; }
|
||||||
|
public string ArtistName { get; set; }
|
||||||
|
public string ArtistSlug { get; set; }
|
||||||
|
public string CleanTitle { get; set; }
|
||||||
|
public string SortTitle { get; set; }
|
||||||
|
//public SeriesStatusType Status { get; set; }
|
||||||
|
public string Overview { get; set; }
|
||||||
|
public bool Monitored { get; set; }
|
||||||
|
//public int ProfileId { get; set; }
|
||||||
|
public bool AlbumFolder { get; set; }
|
||||||
|
public DateTime? LastInfoSync { get; set; }
|
||||||
|
//public int Runtime { get; set; }
|
||||||
|
public List<MediaCover.MediaCover> Images { get; set; }
|
||||||
|
//public SeriesTypes SeriesType { get; set; }
|
||||||
|
//public string Network { get; set; }
|
||||||
|
//public bool UseSceneNumbering { get; set; }
|
||||||
|
//public string TitleSlug { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
//public int Year { get; set; }
|
||||||
|
//public Ratings Ratings { get; set; }
|
||||||
|
public List<string> Genres { get; set; }
|
||||||
|
//public List<Actor> Actors { get; set; } // MOve to album?
|
||||||
|
public string Certification { get; set; }
|
||||||
|
public string RootFolderPath { get; set; }
|
||||||
|
public DateTime Added { get; set; }
|
||||||
|
public DateTime? FirstAired { get; set; }
|
||||||
|
public LazyLoaded<Profile> Profile { get; set; }
|
||||||
|
public int ProfileId { get; set; }
|
||||||
|
|
||||||
|
public List<Album> Albums { get; set; }
|
||||||
|
public HashSet<int> Tags { get; set; }
|
||||||
|
//public AddSeriesOptions AddOptions { get; set; } // TODO: Learn what this does
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("[{0}][{1}]", ItunesId, ArtistName.NullSafe());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyChanges(Artist otherArtist)
|
||||||
|
{
|
||||||
|
//TODO: Implement
|
||||||
|
ItunesId = otherArtist.ItunesId;
|
||||||
|
|
||||||
|
Albums = otherArtist.Albums;
|
||||||
|
Path = otherArtist.Path;
|
||||||
|
ProfileId = otherArtist.ProfileId;
|
||||||
|
|
||||||
|
AlbumFolder = otherArtist.AlbumFolder;
|
||||||
|
Monitored = otherArtist.Monitored;
|
||||||
|
|
||||||
|
//SeriesType = otherArtist.SeriesType;
|
||||||
|
RootFolderPath = otherArtist.RootFolderPath;
|
||||||
|
Tags = otherArtist.Tags;
|
||||||
|
//AddOptions = otherArtist.AddOptions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
src/NzbDrone.Core/Music/Compilation.cs
Normal file
19
src/NzbDrone.Core/Music/Compilation.cs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Music
|
||||||
|
{
|
||||||
|
public class Compilation : ModelBase
|
||||||
|
{
|
||||||
|
public Compilation()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompilationId { get; set; }
|
||||||
|
public LazyList<Artist> Artists { get; set; }
|
||||||
|
}
|
||||||
|
}
|
51
src/NzbDrone.Core/Music/Track.cs
Normal file
51
src/NzbDrone.Core/Music/Track.cs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using Marr.Data;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Music
|
||||||
|
{
|
||||||
|
public class Track : ModelBase
|
||||||
|
{
|
||||||
|
public Track()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public const string RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
||||||
|
|
||||||
|
public int ItunesTrackId { get; set; }
|
||||||
|
public int AlbumId { get; set; }
|
||||||
|
public int CompilationId { get; set; }
|
||||||
|
public bool Compilation { get; set; }
|
||||||
|
public int TrackNumber { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public bool Ignored { get; set; }
|
||||||
|
public bool Explict { get; set; }
|
||||||
|
public string TrackExplicitName { get; set; }
|
||||||
|
public string TrackCensoredName { get; set; }
|
||||||
|
public string Monitored { get; set; }
|
||||||
|
public int TrackFileId { get; set; } // JVM: Is this needed with TrackFile reference?
|
||||||
|
public DateTime? ReleaseDate { get; set; }
|
||||||
|
/*public int? SceneEpisodeNumber { get; set; }
|
||||||
|
public bool UnverifiedSceneNumbering { get; set; }
|
||||||
|
public Ratings Ratings { get; set; } // This might be aplicable as can be pulled from IDv3 tags
|
||||||
|
public List<MediaCover.MediaCover> Images { get; set; }*/
|
||||||
|
|
||||||
|
//public string SeriesTitle { get; private set; }
|
||||||
|
|
||||||
|
public LazyLoaded<TrackFile> TrackFile { get; set; }
|
||||||
|
|
||||||
|
public Album Album { get; set; }
|
||||||
|
|
||||||
|
public bool HasFile => TrackFileId > 0;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("[{0}]{1}", ItunesTrackId, Title.NullSafe());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -287,6 +287,7 @@
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Datastore\Migration\105_rename_torrent_downloadstation.cs" />
|
<Compile Include="Datastore\Migration\105_rename_torrent_downloadstation.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\111_setup_music.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||||
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
|
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
|
||||||
|
@ -781,6 +782,7 @@
|
||||||
<Compile Include="MediaFiles\RenameEpisodeFilePreview.cs" />
|
<Compile Include="MediaFiles\RenameEpisodeFilePreview.cs" />
|
||||||
<Compile Include="MediaFiles\RenameEpisodeFileService.cs" />
|
<Compile Include="MediaFiles\RenameEpisodeFileService.cs" />
|
||||||
<Compile Include="MediaFiles\SameFilenameException.cs" />
|
<Compile Include="MediaFiles\SameFilenameException.cs" />
|
||||||
|
<Compile Include="MediaFiles\TrackFile.cs" />
|
||||||
<Compile Include="MediaFiles\UpdateEpisodeFileService.cs" />
|
<Compile Include="MediaFiles\UpdateEpisodeFileService.cs" />
|
||||||
<Compile Include="MediaFiles\UpgradeMediaFileService.cs" />
|
<Compile Include="MediaFiles\UpgradeMediaFileService.cs" />
|
||||||
<Compile Include="Messaging\Commands\BackendCommandAttribute.cs" />
|
<Compile Include="Messaging\Commands\BackendCommandAttribute.cs" />
|
||||||
|
@ -837,6 +839,9 @@
|
||||||
<Compile Include="Extras\Metadata\MetadataType.cs" />
|
<Compile Include="Extras\Metadata\MetadataType.cs" />
|
||||||
<Compile Include="MetadataSource\IProvideSeriesInfo.cs" />
|
<Compile Include="MetadataSource\IProvideSeriesInfo.cs" />
|
||||||
<Compile Include="MetadataSource\ISearchForNewSeries.cs" />
|
<Compile Include="MetadataSource\ISearchForNewSeries.cs" />
|
||||||
|
<Compile Include="Music\Album.cs" />
|
||||||
|
<Compile Include="Music\Artist.cs" />
|
||||||
|
<Compile Include="Music\Track.cs" />
|
||||||
<Compile Include="Notifications\Join\JoinAuthException.cs" />
|
<Compile Include="Notifications\Join\JoinAuthException.cs" />
|
||||||
<Compile Include="Notifications\Join\JoinInvalidDeviceException.cs" />
|
<Compile Include="Notifications\Join\JoinInvalidDeviceException.cs" />
|
||||||
<Compile Include="Notifications\Join\JoinResponseModel.cs" />
|
<Compile Include="Notifications\Join\JoinResponseModel.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue