mirror of https://github.com/lidarr/Lidarr
Added Music models and basic database
This commit is contained in:
parent
80e8ef4c7a
commit
ad23e8ce9f
|
@ -9,6 +9,7 @@ using NzbDrone.Core.Test.Framework;
|
|||
using NzbDrone.Test.Common;
|
||||
using FluentAssertions;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.DataAugmentation;
|
||||
|
||||
namespace NzbDrone.Core.Test.DataAugmentation.Scene
|
||||
{
|
||||
|
|
|
@ -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.");
|
||||
// }
|
||||
// }
|
||||
|
||||
// RefreshCache();
|
||||
_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.");
|
||||
}
|
||||
}
|
||||
|
||||
// _eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent());
|
||||
// }
|
||||
RefreshCache();
|
||||
|
||||
// private SceneMapping FindMapping(string title)
|
||||
// {
|
||||
// if (_getTvdbIdCache.Count == 0)
|
||||
// {
|
||||
// RefreshCache();
|
||||
// }
|
||||
_eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent());
|
||||
}
|
||||
|
||||
// var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle());
|
||||
private SceneMapping FindMapping(string title)
|
||||
{
|
||||
if (_getTvdbIdCache.Count == 0)
|
||||
{
|
||||
RefreshCache();
|
||||
}
|
||||
|
||||
// if (candidates == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
var candidates = _getTvdbIdCache.Find(title.CleanSeriesTitle());
|
||||
|
||||
// if (candidates.Count == 1)
|
||||
// {
|
||||
// return candidates.First();
|
||||
// }
|
||||
if (candidates == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber)
|
||||
// .FirstOrDefault(v => v.Title == title);
|
||||
if (candidates.Count == 1)
|
||||
{
|
||||
return candidates.First();
|
||||
}
|
||||
|
||||
// if (exactMatch != null)
|
||||
// {
|
||||
// return exactMatch;
|
||||
// }
|
||||
var exactMatch = candidates.OrderByDescending(v => v.SeasonNumber)
|
||||
.FirstOrDefault(v => v.Title == title);
|
||||
|
||||
// var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10))
|
||||
// .ThenByDescending(v => v.SeasonNumber)
|
||||
// .First();
|
||||
if (exactMatch != null)
|
||||
{
|
||||
return exactMatch;
|
||||
}
|
||||
|
||||
// return closestMatch;
|
||||
// }
|
||||
var closestMatch = candidates.OrderBy(v => title.LevenshteinDistance(v.Title, 10, 1, 10))
|
||||
.ThenByDescending(v => v.SeasonNumber)
|
||||
.First();
|
||||
|
||||
// private void RefreshCache()
|
||||
// {
|
||||
// var mappings = _repository.All().ToList();
|
||||
return closestMatch;
|
||||
}
|
||||
|
||||
// _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 void RefreshCache()
|
||||
{
|
||||
var mappings = _repository.All().ToList();
|
||||
|
||||
// private List<string> FilterNonEnglish(List<string> titles)
|
||||
// {
|
||||
// return titles.Where(title => title.All(c => c <= 255)).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()));
|
||||
}
|
||||
|
||||
// public void Handle(SeriesRefreshStartingEvent message)
|
||||
// {
|
||||
// if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1)))
|
||||
// {
|
||||
// UpdateMappings();
|
||||
// }
|
||||
// }
|
||||
private List<string> FilterNonEnglish(List<string> titles)
|
||||
{
|
||||
return titles.Where(title => title.All(c => c <= 255)).ToList();
|
||||
}
|
||||
|
||||
// public void Execute(UpdateSceneMappingCommand message)
|
||||
// {
|
||||
// UpdateMappings();
|
||||
// }
|
||||
//}
|
||||
public void Handle(SeriesRefreshStartingEvent message)
|
||||
{
|
||||
if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1)))
|
||||
{
|
||||
UpdateMappings();
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(UpdateSceneMappingCommand message)
|
||||
{
|
||||
UpdateMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
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("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("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?
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ using NzbDrone.Core.Extras.Metadata.Files;
|
|||
using NzbDrone.Core.Extras.Others;
|
||||
using NzbDrone.Core.Extras.Subtitles;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
|
@ -91,6 +92,26 @@ namespace NzbDrone.Core.Datastore
|
|||
.Relationship()
|
||||
.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<QualityDefinition>().RegisterModel("QualityDefinitions")
|
||||
.Ignore(d => d.Weight);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
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 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>
|
||||
</Compile>
|
||||
<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\MigrationController.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
|
||||
|
@ -781,6 +782,7 @@
|
|||
<Compile Include="MediaFiles\RenameEpisodeFilePreview.cs" />
|
||||
<Compile Include="MediaFiles\RenameEpisodeFileService.cs" />
|
||||
<Compile Include="MediaFiles\SameFilenameException.cs" />
|
||||
<Compile Include="MediaFiles\TrackFile.cs" />
|
||||
<Compile Include="MediaFiles\UpdateEpisodeFileService.cs" />
|
||||
<Compile Include="MediaFiles\UpgradeMediaFileService.cs" />
|
||||
<Compile Include="Messaging\Commands\BackendCommandAttribute.cs" />
|
||||
|
@ -837,6 +839,9 @@
|
|||
<Compile Include="Extras\Metadata\MetadataType.cs" />
|
||||
<Compile Include="MetadataSource\IProvideSeriesInfo.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\JoinInvalidDeviceException.cs" />
|
||||
<Compile Include="Notifications\Join\JoinResponseModel.cs" />
|
||||
|
|
Loading…
Reference in New Issue