2014-02-07 04:10:13 +01:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Configuration;
|
2013-12-26 17:53:23 +01:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2015-01-26 17:47:15 +01:00
|
|
|
|
using MediaBrowser.Model.Users;
|
2013-09-11 19:54:59 +02:00
|
|
|
|
using System.Collections.Generic;
|
2013-09-10 20:56:00 +02:00
|
|
|
|
using System.Linq;
|
2013-02-21 02:33:05 +01:00
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities.Audio
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class MusicAlbum
|
|
|
|
|
/// </summary>
|
2014-07-18 02:39:07 +02:00
|
|
|
|
public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasLookupInfo<AlbumInfo>
|
2013-02-21 02:33:05 +01:00
|
|
|
|
{
|
2013-09-10 20:56:00 +02:00
|
|
|
|
public MusicAlbum()
|
|
|
|
|
{
|
2014-08-29 02:49:25 +02:00
|
|
|
|
Artists = new List<string>();
|
|
|
|
|
AlbumArtists = new List<string>();
|
2013-09-10 20:56:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-30 16:26:29 +02:00
|
|
|
|
[IgnoreDataMember]
|
2014-08-06 01:59:24 +02:00
|
|
|
|
public override bool SupportsAddingToPlaylist
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 23:40:03 +01:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public MusicArtist MusicArtist
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Parents.OfType<MusicArtist>().FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-07 04:51:52 +02:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public List<string> AllArtists
|
2014-06-23 18:05:19 +02:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-08-29 02:49:25 +02:00
|
|
|
|
var list = AlbumArtists.ToList();
|
2014-06-23 18:05:19 +02:00
|
|
|
|
|
|
|
|
|
list.AddRange(Artists);
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-28 19:10:26 +01:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public string AlbumArtist
|
|
|
|
|
{
|
|
|
|
|
get { return AlbumArtists.FirstOrDefault(); }
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-29 02:49:25 +02:00
|
|
|
|
public List<string> AlbumArtists { get; set; }
|
2014-04-07 04:51:52 +02:00
|
|
|
|
|
2014-06-29 19:58:04 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the tracks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The tracks.</value>
|
|
|
|
|
public IEnumerable<Audio> Tracks
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2015-01-25 07:34:50 +01:00
|
|
|
|
return GetRecursiveChildren(i => i is Audio).Cast<Audio>();
|
2014-06-29 19:58:04 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
|
|
|
|
{
|
|
|
|
|
return Tracks;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-11 19:54:59 +02:00
|
|
|
|
public List<string> Artists { get; set; }
|
2013-10-02 01:33:50 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the user data key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>System.String.</returns>
|
2015-01-24 23:33:26 +01:00
|
|
|
|
protected override string CreateUserDataKey()
|
2013-10-02 01:33:50 +02:00
|
|
|
|
{
|
|
|
|
|
var id = this.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
|
|
|
|
|
|
2014-11-12 05:51:40 +01:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(id))
|
2013-10-02 01:33:50 +02:00
|
|
|
|
{
|
2013-10-05 02:44:43 +02:00
|
|
|
|
return "MusicAlbum-MusicBrainzReleaseGroup-" + id;
|
2013-10-02 01:33:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 23:40:03 +01:00
|
|
|
|
id = this.GetProviderId(MetadataProviders.MusicBrainzAlbum);
|
2013-10-02 01:33:50 +02:00
|
|
|
|
|
2014-11-12 05:51:40 +01:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(id))
|
2013-10-02 01:33:50 +02:00
|
|
|
|
{
|
2013-10-05 02:44:43 +02:00
|
|
|
|
return "MusicAlbum-Musicbrainz-" + id;
|
2013-10-02 01:33:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-24 23:33:26 +01:00
|
|
|
|
return base.CreateUserDataKey();
|
2013-10-02 01:33:50 +02:00
|
|
|
|
}
|
2013-12-26 17:53:23 +01:00
|
|
|
|
|
2014-12-20 07:06:27 +01:00
|
|
|
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
2013-12-26 17:53:23 +01:00
|
|
|
|
{
|
2014-02-21 16:24:29 +01:00
|
|
|
|
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
2013-12-26 17:53:23 +01:00
|
|
|
|
}
|
2014-02-07 04:10:13 +01:00
|
|
|
|
|
|
|
|
|
public AlbumInfo GetLookupInfo()
|
|
|
|
|
{
|
|
|
|
|
var id = GetItemLookupInfo<AlbumInfo>();
|
|
|
|
|
|
2014-06-23 18:05:19 +02:00
|
|
|
|
id.AlbumArtists = AlbumArtists;
|
2014-02-07 04:10:13 +01:00
|
|
|
|
|
|
|
|
|
var artist = Parents.OfType<MusicArtist>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (artist != null)
|
|
|
|
|
{
|
|
|
|
|
id.ArtistProviderIds = artist.ProviderIds;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-25 07:34:50 +01:00
|
|
|
|
id.SongInfos = GetRecursiveChildren(i => i is Audio)
|
|
|
|
|
.Cast<Audio>()
|
2014-02-07 04:10:13 +01:00
|
|
|
|
.Select(i => i.GetLookupInfo())
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
2013-02-21 02:33:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|