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);
        }
Ejemplo n.º 2
0
        public MediaLibraryAudioBroadcastItem(string title, int channelNr, EndPointSettings client)
            : base(DlnaResourceAccessUtils.RADIO_CHANNEL_RESOURCE + channelNr, client)
        {
            Id           = Key;
            Title        = title;
            ChannelName  = title;
            ChannelNr    = channelNr;
            Date         = DateTime.Now.ToString("yyyy-MM-dd");
            AlbumArtUrls = new List <IDirectoryAlbumArt>();

            var albumArt = new MediaLibraryAlbumArt(Guid.Empty, client);

            albumArt.Initialise(title, false);
            AlbumArtUrls.Add(albumArt);

            if (client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Icon)
            {
                Icon = albumArt.Uri;
            }
            if (client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Resource)
            {
                var albumResource = new MediaLibraryAlbumArtResource(albumArt);
                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 MediaLibraryLiveResource(Key, channelNr, client);

            resource.Initialise();
            Resources.Add(resource);
        }
Ejemplo n.º 3
0
        public MediaLibraryAlbumItem(MediaItem item, EndPointSettings client)
            : base(item, NECESSARY_MUSIC_MIA_TYPE_IDS, OPTIONAL_MUSIC_MIA_TYPE_IDS,
                   new RelationshipFilter(AudioAspect.ROLE_TRACK, AudioAlbumAspect.ROLE_ALBUM, item.MediaItemId), client)
        {
            Genre       = new List <string>();
            Artist      = new List <string>();
            Contributor = new List <string>();

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

                    var artistObj = albumAspect.GetCollectionAttribute <object>(AudioAlbumAspect.ATTR_ARTISTS);
                    if (artistObj != null)
                    {
                        CollectionUtils.AddAll(Artist, artistObj.Cast <string>());
                    }

                    Description     = albumAspect.GetAttributeValue <string>(AudioAlbumAspect.ATTR_DESCRIPTION);
                    LongDescription = Description;
                }
            }

            //Support alternative ways to get album art
            var albumArt = new MediaLibraryAlbumArt(item, Client);

            if (albumArt != null)
            {
                albumArt.Initialise();
                if (Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Resource)
                {
                    var albumResource = new MediaLibraryAlbumArtResource(albumArt);
                    albumResource.Initialise();
                    Resources.Add(albumResource);
                }
                if (Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.AlbumArt)
                {
                    AlbumArtUrl = albumArt.Uri;
                }
            }
        }
        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);
        }
Ejemplo n.º 5
0
        public MediaLibrarySeasonItem(MediaItem item, EndPointSettings client)
            : base(item, NECESSARY_EPISODE_MIA_TYPE_IDS, OPTIONAL_EPISODE_MIA_TYPE_IDS,
                   new RelationshipFilter(EpisodeAspect.ROLE_EPISODE, SeasonAspect.ROLE_SEASON, item.MediaItemId), client)
        {
            Genre       = new List <string>();
            Artist      = new List <string>();
            Contributor = new List <string>();

            if (Client.Profile.Settings.Metadata.Delivery == MetadataDelivery.All)
            {
                SingleMediaItemAspect seriesAspect;
                if (MediaItemAspect.TryGetAspect(item.Aspects, SeasonAspect.Metadata, out seriesAspect))
                {
                    var descriptionObj = seriesAspect.GetAttributeValue(SeasonAspect.ATTR_DESCRIPTION);
                    if (descriptionObj != null)
                    {
                        Description = descriptionObj.ToString();
                    }
                }
            }

            //Support alternative ways to get album art
            var albumArt = new MediaLibraryAlbumArt(item, Client);

            if (albumArt != null)
            {
                albumArt.Initialise();
                if (Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.Resource)
                {
                    var albumResource = new MediaLibraryAlbumArtResource(albumArt);
                    albumResource.Initialise();
                    Resources.Add(albumResource);
                }
                if (Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.All || Client.Profile.Settings.Thumbnails.Delivery == ThumbnailDelivery.AlbumArt)
                {
                    AlbumArtUrl = albumArt.Uri;
                }
            }
        }
        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);
                }
            }
        }