public MediaLibraryImageItem(MediaItem item, EndPointSettings client)
            : base(item, client)
        {
            Publisher = new List <string>();
            Rights    = new List <string>();
            object oValue = MediaItemAspect.GetAspect(item.Aspects, MediaAspect.Metadata).GetAttributeValue(MediaAspect.ATTR_RECORDINGTIME);

            if (oValue != null)
            {
                Date = Convert.ToDateTime(oValue).Date.ToString("yyyy-MM-dd");
            }

            //Support alternative ways to get thumbnail
            if (AlbumArtUrls.Count > 0)
            {
                if (client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Resource)
                {
                    var albumResource = new MediaLibraryAlbumArtResource((MediaLibraryAlbumArt)AlbumArtUrls[0]);
                    albumResource.Initialise();
                    Resources.Add(albumResource);
                }
                if (client.Profile.Settings.Thumbnails.Delivery != ThumbnailDelivery.All && client.Profile.Settings.Thumbnails.Delivery != ThumbnailDelivery.AlbumArt)
                {
                    AlbumArtUrls.Clear();
                }
            }

            var resource = new MediaLibraryResource(client);

            resource.Initialise(item);
            Resources.Add(resource);
        }
        public MediaLibraryAudioItem(MediaItem item, EndPointSettings client)
            : base(item, client)
        {
            Genre     = new List <string>();
            Publisher = new List <string>();
            Rights    = new List <string>();

            if (MediaItemAspect.TryGetAspect(item.Aspects, AudioAspect.Metadata, out SingleMediaItemAspect audioAspect))
            {
                Title = audioAspect.GetAttributeValue <string>(AudioAspect.ATTR_TRACKNAME);
            }

            if (client.Profile.Settings.Metadata.Delivery == MetadataDelivery.All)
            {
                if (MediaItemAspect.TryGetAspects(item.Aspects, GenreAspect.Metadata, out IList <MultipleMediaItemAspect> genreAspects))
                {
                    CollectionUtils.AddAll(Genre, genreAspects.Select(g => g.GetAttributeValue <string>(GenreAspect.ATTR_GENRE)));
                }
            }

            //Support alternative ways to get album art
            if (AlbumArtUrls.Count > 0)
            {
                if (client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Resource)
                {
                    var albumResource = new MediaLibraryAlbumArtResource((MediaLibraryAlbumArt)AlbumArtUrls[0]);
                    albumResource.Initialise();
                    Resources.Add(albumResource);
                }
                if (client.Profile.Settings.Thumbnails.Delivery != ThumbnailDelivery.All && client.Profile.Settings.Thumbnails.Delivery != ThumbnailDelivery.AlbumArt)
                {
                    AlbumArtUrls.Clear();
                }
            }

            var resource = new MediaLibraryResource(client);

            resource.Initialise(item);
            Resources.Add(resource);
        }
        public MediaLibraryVideoItem(MediaItem item, EndPointSettings client)
            : base(item, client)
        {
            Genre     = new List <string>();
            Producer  = new List <string>();
            Actor     = new List <string>();
            Director  = new List <string>();
            Publisher = new List <string>();

            if (item.Aspects.ContainsKey(MovieAspect.ASPECT_ID))
            {
                Title = item.Aspects[MovieAspect.ASPECT_ID].First().GetAttributeValue <string>(MovieAspect.ATTR_MOVIE_NAME);
            }
            else if (item.Aspects.ContainsKey(EpisodeAspect.ASPECT_ID))
            {
                Title = item.Aspects[EpisodeAspect.ASPECT_ID].First().GetAttributeValue <string>(EpisodeAspect.ATTR_EPISODE_NAME);
            }

            if (client.Profile.Settings.Metadata.Delivery == MetadataDelivery.All)
            {
                if (MediaItemAspect.TryGetAspect(item.Aspects, VideoAspect.Metadata, out SingleMediaItemAspect videoAspect))
                {
                    if (MediaItemAspect.TryGetAspects(item.Aspects, GenreAspect.Metadata, out IList <MultipleMediaItemAspect> genreAspects))
                    {
                        CollectionUtils.AddAll(Genre, genreAspects.Select(g => g.GetAttributeValue <string>(GenreAspect.ATTR_GENRE)));
                    }

                    var actorObj = videoAspect.GetCollectionAttribute <object>(VideoAspect.ATTR_ACTORS);
                    if (actorObj != null)
                    {
                        CollectionUtils.AddAll(Actor, actorObj.Cast <string>());
                    }

                    var directorsObj = videoAspect.GetCollectionAttribute <object>(VideoAspect.ATTR_DIRECTORS);
                    if (directorsObj != null)
                    {
                        CollectionUtils.AddAll(Director, directorsObj.Cast <string>());
                    }

                    var descriptionObj = videoAspect.GetAttributeValue(VideoAspect.ATTR_STORYPLOT);
                    if (descriptionObj != null)
                    {
                        Description = descriptionObj.ToString();
                    }
                }
            }

            if (MediaItemAspect.TryGetAspect(item.Aspects, MediaAspect.Metadata, out SingleMediaItemAspect mediaAspect))
            {
                object oValue = mediaAspect.GetAttributeValue(MediaAspect.ATTR_RECORDINGTIME);
                if (oValue != null)
                {
                    Date = Convert.ToDateTime(oValue).Date.ToString("yyyy-MM-dd");
                }
            }

            //Support alternative ways to get cover
            if (AlbumArtUrls.Count > 0)
            {
                if (client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Icon)
                {
                    Icon = AlbumArtUrls[0].Uri;
                }
                if (client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Resource)
                {
                    var albumResource = new MediaLibraryAlbumArtResource((MediaLibraryAlbumArt)AlbumArtUrls[0]);
                    albumResource.Initialise();
                    Resources.Add(albumResource);
                }
                if (client.Profile.Settings.Thumbnails.Delivery != ThumbnailDelivery.All && client.Profile.Settings.Thumbnails.Delivery != ThumbnailDelivery.AlbumArt)
                {
                    AlbumArtUrls.Clear();
                }
            }

            var resource = new MediaLibraryResource(client);

            resource.Initialise(item);
            Resources.Add(resource);

            if (client.Profile.MediaTranscoding?.SubtitleSettings?.SubtitleMode == SubtitleSupport.SoftCoded)
            {
                MediaLibrarySubtitle sub = new MediaLibrarySubtitle(item, client);
                sub.Initialise();
                if (string.IsNullOrEmpty(sub.Uri) == false)
                {
                    var subResource = new MediaLibrarySubtitleResource(sub);
                    subResource.Initialise();
                    Resources.Add(subResource);
                }
            }
        }