2017-04-20 23:19:47 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2019-07-09 20:14:05 +00:00
|
|
|
using System.Linq;
|
2021-07-11 20:31:22 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2020-01-03 12:49:24 +00:00
|
|
|
using Equ;
|
|
|
|
using NzbDrone.Common.Extensions;
|
2020-08-18 20:11:44 +00:00
|
|
|
using NzbDrone.Core.Datastore;
|
2017-04-20 23:19:47 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Music
|
|
|
|
{
|
2019-08-27 20:23:35 +00:00
|
|
|
public class Album : Entity<Album>
|
2017-04-20 23:19:47 +00:00
|
|
|
{
|
|
|
|
public Album()
|
|
|
|
{
|
2019-08-27 20:23:35 +00:00
|
|
|
OldForeignAlbumIds = new List<string>();
|
2019-12-16 21:21:32 +00:00
|
|
|
Overview = string.Empty;
|
2017-04-20 23:19:47 +00:00
|
|
|
Images = new List<MediaCover.MediaCover>();
|
2018-12-15 00:02:43 +00:00
|
|
|
Links = new List<Links>();
|
2019-08-27 20:23:35 +00:00
|
|
|
Genres = new List<string>();
|
|
|
|
SecondaryTypes = new List<SecondaryAlbumType>();
|
2018-04-08 06:48:34 +00:00
|
|
|
Ratings = new Ratings();
|
2018-12-15 00:02:43 +00:00
|
|
|
Artist = new Artist();
|
2019-12-16 21:21:32 +00:00
|
|
|
AddOptions = new AddAlbumOptions();
|
2019-08-27 20:23:35 +00:00
|
|
|
}
|
2017-06-28 02:25:51 +00:00
|
|
|
|
2018-12-15 00:02:43 +00:00
|
|
|
// These correspond to columns in the Albums table
|
|
|
|
// These are metadata entries
|
|
|
|
public int ArtistMetadataId { get; set; }
|
2017-06-18 02:27:01 +00:00
|
|
|
public string ForeignAlbumId { get; set; }
|
2019-07-09 20:13:52 +00:00
|
|
|
public List<string> OldForeignAlbumIds { get; set; }
|
2017-06-25 13:17:49 +00:00
|
|
|
public string Title { get; set; }
|
2018-12-15 00:02:43 +00:00
|
|
|
public string Overview { get; set; }
|
2018-07-20 22:33:56 +00:00
|
|
|
public string Disambiguation { get; set; }
|
2017-06-28 02:25:51 +00:00
|
|
|
public DateTime? ReleaseDate { get; set; }
|
2017-04-20 23:19:47 +00:00
|
|
|
public List<MediaCover.MediaCover> Images { get; set; }
|
2018-12-15 00:02:43 +00:00
|
|
|
public List<Links> Links { get; set; }
|
2017-04-30 16:34:53 +00:00
|
|
|
public List<string> Genres { get; set; }
|
2019-12-16 21:21:32 +00:00
|
|
|
public string AlbumType { get; set; }
|
2017-11-26 03:51:37 +00:00
|
|
|
public List<SecondaryAlbumType> SecondaryTypes { get; set; }
|
2017-06-25 13:17:49 +00:00
|
|
|
public Ratings Ratings { get; set; }
|
2018-12-15 00:02:43 +00:00
|
|
|
|
2020-01-03 12:49:24 +00:00
|
|
|
// These are Lidarr generated/config
|
2018-12-15 00:02:43 +00:00
|
|
|
public string CleanTitle { get; set; }
|
|
|
|
public int ProfileId { get; set; }
|
|
|
|
public bool Monitored { get; set; }
|
|
|
|
public bool AnyReleaseOk { get; set; }
|
|
|
|
public DateTime? LastInfoSync { get; set; }
|
|
|
|
public DateTime Added { get; set; }
|
2019-08-27 20:23:35 +00:00
|
|
|
[MemberwiseEqualityIgnore]
|
2019-12-16 21:21:32 +00:00
|
|
|
public AddAlbumOptions AddOptions { get; set; }
|
2018-12-15 00:02:43 +00:00
|
|
|
|
|
|
|
// These are dynamically queried from other tables
|
2019-08-27 20:23:35 +00:00
|
|
|
[MemberwiseEqualityIgnore]
|
2018-12-15 00:02:43 +00:00
|
|
|
public LazyLoaded<ArtistMetadata> ArtistMetadata { get; set; }
|
2019-08-27 20:23:35 +00:00
|
|
|
[MemberwiseEqualityIgnore]
|
2018-12-15 00:02:43 +00:00
|
|
|
public LazyLoaded<List<AlbumRelease>> AlbumReleases { get; set; }
|
2019-08-27 20:23:35 +00:00
|
|
|
[MemberwiseEqualityIgnore]
|
2018-12-15 00:02:43 +00:00
|
|
|
public LazyLoaded<Artist> Artist { get; set; }
|
|
|
|
|
2022-11-22 01:51:00 +00:00
|
|
|
// compatibility properties with old version of Album
|
2019-08-27 20:23:35 +00:00
|
|
|
[MemberwiseEqualityIgnore]
|
2020-08-18 20:11:44 +00:00
|
|
|
[JsonIgnore]
|
2020-01-03 12:49:24 +00:00
|
|
|
public int ArtistId
|
|
|
|
{
|
|
|
|
get { return Artist?.Value?.Id ?? 0; } set { Artist.Value.Id = value; }
|
|
|
|
}
|
2017-06-18 02:27:01 +00:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return string.Format("[{0}][{1}]", ForeignAlbumId, Title.NullSafe());
|
|
|
|
}
|
2018-01-18 02:28:47 +00:00
|
|
|
|
2019-08-27 20:23:35 +00:00
|
|
|
public override void UseMetadataFrom(Album other)
|
2018-01-18 02:28:47 +00:00
|
|
|
{
|
2019-08-27 20:23:35 +00:00
|
|
|
ForeignAlbumId = other.ForeignAlbumId;
|
|
|
|
OldForeignAlbumIds = other.OldForeignAlbumIds;
|
|
|
|
Title = other.Title;
|
|
|
|
Overview = other.Overview.IsNullOrWhiteSpace() ? Overview : other.Overview;
|
|
|
|
Disambiguation = other.Disambiguation;
|
|
|
|
ReleaseDate = other.ReleaseDate;
|
|
|
|
Images = other.Images.Any() ? other.Images : Images;
|
|
|
|
Links = other.Links;
|
|
|
|
Genres = other.Genres;
|
|
|
|
AlbumType = other.AlbumType;
|
|
|
|
SecondaryTypes = other.SecondaryTypes;
|
|
|
|
Ratings = other.Ratings;
|
|
|
|
CleanTitle = other.CleanTitle;
|
2018-01-18 02:28:47 +00:00
|
|
|
}
|
2019-07-09 20:14:05 +00:00
|
|
|
|
2019-08-27 20:23:35 +00:00
|
|
|
public override void UseDbFieldsFrom(Album other)
|
2019-07-09 20:14:05 +00:00
|
|
|
{
|
2019-08-27 20:23:35 +00:00
|
|
|
Id = other.Id;
|
|
|
|
ArtistMetadataId = other.ArtistMetadataId;
|
|
|
|
ProfileId = other.ProfileId;
|
|
|
|
Monitored = other.Monitored;
|
|
|
|
AnyReleaseOk = other.AnyReleaseOk;
|
|
|
|
LastInfoSync = other.LastInfoSync;
|
|
|
|
Added = other.Added;
|
|
|
|
AddOptions = other.AddOptions;
|
2019-07-09 20:14:05 +00:00
|
|
|
}
|
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
public override void ApplyChanges(Album other)
|
2019-07-09 20:14:05 +00:00
|
|
|
{
|
2019-12-16 21:21:32 +00:00
|
|
|
ForeignAlbumId = other.ForeignAlbumId;
|
|
|
|
ProfileId = other.ProfileId;
|
|
|
|
AddOptions = other.AddOptions;
|
|
|
|
Monitored = other.Monitored;
|
|
|
|
AnyReleaseOk = other.AnyReleaseOk;
|
2019-07-09 20:14:05 +00:00
|
|
|
}
|
2017-04-20 23:19:47 +00:00
|
|
|
}
|
|
|
|
}
|