예제 #1
0
        public void NavigateTo(BaseItemInfo item)
        {
            var dto = new BaseItemDto
            {
                Id = item.Id,
                Type = item.Type,
                Name = item.Name
            };

            NavigateTo(dto);
        }
예제 #2
0
        public void ReportNowViewingItem(string sessionId, BaseItemInfo item)
        {
            var session = GetSession(sessionId);

            session.NowViewingItem = item;
        }
예제 #3
0
        /// <summary>
        /// Converts a BaseItem to a BaseItemInfo
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>BaseItemInfo.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public static BaseItemInfo GetBaseItemInfo(BaseItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var info = new BaseItemInfo
            {
                Id = GetClientItemId(item),
                Name = item.Name,
                MediaType = item.MediaType,
                Type = item.GetType().Name,
                IsFolder = item.IsFolder,
                RunTimeTicks = item.RunTimeTicks
            };

            var imagePath = item.PrimaryImagePath;

            if (!string.IsNullOrEmpty(imagePath))
            {
                try
                {
                    info.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, imagePath);
                }
                catch (IOException)
                {
                }
            }

            return info;
        }
예제 #4
0
        /// <summary>
        /// Converts a BaseItem to a BaseItemInfo
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="chapterOwner">The chapter owner.</param>
        /// <param name="mediaSourceId">The media source identifier.</param>
        /// <returns>BaseItemInfo.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        private BaseItemInfo GetItemInfo(BaseItem item, BaseItem chapterOwner, string mediaSourceId)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var info = new BaseItemInfo
            {
                Id = GetDtoId(item),
                Name = item.Name,
                MediaType = item.MediaType,
                Type = item.GetClientTypeName(),
                RunTimeTicks = item.RunTimeTicks,
                IndexNumber = item.IndexNumber,
                ParentIndexNumber = item.ParentIndexNumber,
                PremiereDate = item.PremiereDate,
                ProductionYear = item.ProductionYear
            };

            info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
            if (info.PrimaryImageTag != null)
            {
                info.PrimaryImageItemId = GetDtoId(item);
            }

            var episode = item as Episode;
            if (episode != null)
            {
                info.IndexNumberEnd = episode.IndexNumberEnd;
            }

            var hasSeries = item as IHasSeries;
            if (hasSeries != null)
            {
                info.SeriesName = hasSeries.SeriesName;
            }

            var recording = item as ILiveTvRecording;
            if (recording != null && recording.RecordingInfo != null)
            {
                if (recording.RecordingInfo.IsSeries)
                {
                    info.Name = recording.RecordingInfo.EpisodeTitle;
                    info.SeriesName = recording.RecordingInfo.Name;

                    if (string.IsNullOrWhiteSpace(info.Name))
                    {
                        info.Name = recording.RecordingInfo.Name;
                    }
                }
            }

            var audio = item as Audio;
            if (audio != null)
            {
                info.Album = audio.Album;
                info.Artists = audio.Artists;

                if (info.PrimaryImageTag == null)
                {
                    var album = audio.Parents.OfType<MusicAlbum>().FirstOrDefault();

                    if (album != null && album.HasImage(ImageType.Primary))
                    {
                        info.PrimaryImageTag = GetImageCacheTag(album, ImageType.Primary);
                        if (info.PrimaryImageTag != null)
                        {
                            info.PrimaryImageItemId = GetDtoId(album);
                        }
                    }
                }
            }

            var musicVideo = item as MusicVideo;
            if (musicVideo != null)
            {
                info.Album = musicVideo.Album;

                if (!string.IsNullOrWhiteSpace(musicVideo.Artist))
                {
                    info.Artists.Add(musicVideo.Artist);
                }
            }

            var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
            var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
            var logoItem = item.HasImage(ImageType.Logo) ? item : null;

            if (thumbItem == null)
            {
                if (episode != null)
                {
                    var series = episode.Series;

                    if (series != null && series.HasImage(ImageType.Thumb))
                    {
                        thumbItem = series;
                    }
                }
            }

            if (backropItem == null)
            {
                if (episode != null)
                {
                    var series = episode.Series;

                    if (series != null && series.HasImage(ImageType.Backdrop))
                    {
                        backropItem = series;
                    }
                }
            }

            if (backropItem == null)
            {
                backropItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Backdrop));
            }

            if (thumbItem == null)
            {
                thumbItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Thumb));
            }

            if (logoItem == null)
            {
                logoItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Logo));
            }

            if (thumbItem != null)
            {
                info.ThumbImageTag = GetImageCacheTag(thumbItem, ImageType.Thumb);
                info.ThumbItemId = GetDtoId(thumbItem);
            }

            if (backropItem != null)
            {
                info.BackdropImageTag = GetImageCacheTag(backropItem, ImageType.Backdrop);
                info.BackdropItemId = GetDtoId(backropItem);
            }

            if (logoItem != null)
            {
                info.LogoImageTag = GetImageCacheTag(logoItem, ImageType.Logo);
                info.LogoItemId = GetDtoId(logoItem);
            }

            if (chapterOwner != null)
            {
                info.ChapterImagesItemId = chapterOwner.Id.ToString("N");

                info.Chapters = _itemRepo.GetChapters(chapterOwner.Id).Select(i => _dtoService.GetChapterInfoDto(i, chapterOwner)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(mediaSourceId))
            {
                info.MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery
                {
                    ItemId = new Guid(mediaSourceId)

                }).ToList();
            }

            return info;
        }
예제 #5
0
        /// <summary>
        /// Converts a BaseItem to a BaseItemInfo
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>BaseItemInfo.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        public BaseItemInfo GetBaseItemInfo(BaseItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var info = new BaseItemInfo
            {
                Id = GetDtoId(item),
                Name = item.Name,
                MediaType = item.MediaType,
                Type = item.GetClientTypeName(),
                RunTimeTicks = item.RunTimeTicks
            };

            var imagePath = item.PrimaryImagePath;

            if (!string.IsNullOrEmpty(imagePath))
            {
                info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary, imagePath);
            }

            return info;
        }
예제 #6
0
        public void ReportNowViewingItem(string sessionId, BaseItemInfo item, string context)
        {
            var session = GetSession(sessionId);

            session.NowViewingItem = item;
            session.NowViewingContext = context;
        }
예제 #7
0
        /// <summary>
        /// Converts a BaseItem to a BaseItemInfo
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="runtimeTicks">The now playing runtime ticks.</param>
        /// <returns>BaseItemInfo.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        private BaseItemInfo GetItemInfo(BaseItem item, long? runtimeTicks)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var info = new BaseItemInfo
            {
                Id = GetDtoId(item),
                Name = item.Name,
                MediaType = item.MediaType,
                Type = item.GetClientTypeName(),
                RunTimeTicks = runtimeTicks,
                IndexNumber = item.IndexNumber,
                ParentIndexNumber = item.ParentIndexNumber,
                PremiereDate = item.PremiereDate,
                ProductionYear = item.ProductionYear
            };

            info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
            if (info.PrimaryImageTag.HasValue)
            {
                info.PrimaryImageItemId = GetDtoId(item);
            }

            var episode = item as Episode;
            if (episode != null)
            {
                info.IndexNumberEnd = episode.IndexNumberEnd;
            }

            var hasSeries = item as IHasSeries;
            if (hasSeries != null)
            {
                info.SeriesName = hasSeries.SeriesName;
            }

            var recording = item as ILiveTvRecording;
            if (recording != null && recording.RecordingInfo != null)
            {
                if (recording.RecordingInfo.IsSeries)
                {
                    info.Name = recording.RecordingInfo.EpisodeTitle;
                    info.SeriesName = recording.RecordingInfo.Name;

                    if (string.IsNullOrWhiteSpace(info.Name))
                    {
                        info.Name = recording.RecordingInfo.Name;
                    }
                }
            }

            var audio = item as Audio;
            if (audio != null)
            {
                info.Album = audio.Album;
                info.Artists = audio.Artists;

                if (!info.PrimaryImageTag.HasValue)
                {
                    var album = audio.Parents.OfType<MusicAlbum>().FirstOrDefault();

                    if (album != null && album.HasImage(ImageType.Primary))
                    {
                        info.PrimaryImageTag = GetImageCacheTag(album, ImageType.Primary);
                        if (info.PrimaryImageTag.HasValue)
                        {
                            info.PrimaryImageItemId = GetDtoId(album);
                        }
                    }
                }
            }

            var musicVideo = item as MusicVideo;
            if (musicVideo != null)
            {
                info.Album = musicVideo.Album;

                if (!string.IsNullOrWhiteSpace(musicVideo.Artist))
                {
                    info.Artists.Add(musicVideo.Artist);
                }
            }

            var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;
            var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;
            var logoItem = item.HasImage(ImageType.Logo) ? item : null;

            if (thumbItem == null)
            {
                if (episode != null)
                {
                    var series = episode.Series;

                    if (series != null && series.HasImage(ImageType.Thumb))
                    {
                        thumbItem = series;
                    }
                }
            }

            if (backropItem == null)
            {
                if (episode != null)
                {
                    var series = episode.Series;

                    if (series != null && series.HasImage(ImageType.Backdrop))
                    {
                        backropItem = series;
                    }
                }
            }

            if (backropItem == null)
            {
                backropItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Backdrop));
            }

            if (thumbItem == null)
            {
                thumbItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Thumb));
            }

            if (logoItem == null)
            {
                logoItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Logo));
            }

            if (thumbItem != null)
            {
                info.ThumbImageTag = GetImageCacheTag(thumbItem, ImageType.Thumb);
                info.ThumbItemId = GetDtoId(thumbItem);
            }

            if (backropItem != null)
            {
                info.BackdropImageTag = GetImageCacheTag(backropItem, ImageType.Backdrop);
                info.BackdropItemId = GetDtoId(backropItem);
            }

            if (logoItem != null)
            {
                info.LogoImageTag = GetImageCacheTag(logoItem, ImageType.Logo);
                info.LogoItemId = GetDtoId(logoItem);
            }

            return info;
        }
예제 #8
0
        /// <summary>
        /// Converts a BaseItem to a BaseItemInfo
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="mediaSourceId">The media version identifier.</param>
        /// <param name="nowPlayingRuntimeTicks">The now playing runtime ticks.</param>
        /// <returns>BaseItemInfo.</returns>
        /// <exception cref="System.ArgumentNullException">item</exception>
        private BaseItemInfo GetNowPlayingInfo(BaseItem item, string mediaSourceId, long? nowPlayingRuntimeTicks)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            var info = new BaseItemInfo
            {
                Id = GetDtoId(item),
                Name = item.Name,
                MediaType = item.MediaType,
                Type = item.GetClientTypeName(),
                RunTimeTicks = nowPlayingRuntimeTicks,
                MediaSourceId = mediaSourceId
            };

            info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);

            var backropItem = item.HasImage(ImageType.Backdrop) ? item : null;

            var thumbItem = item.HasImage(ImageType.Thumb) ? item : null;

            if (thumbItem == null)
            {
                var episode = item as Episode;

                if (episode != null)
                {
                    var series = episode.Series;

                    if (series != null && series.HasImage(ImageType.Thumb))
                    {
                        thumbItem = series;
                    }
                }
            }

            if (backropItem == null)
            {
                var episode = item as Episode;

                if (episode != null)
                {
                    var series = episode.Series;

                    if (series != null && series.HasImage(ImageType.Backdrop))
                    {
                        backropItem = series;
                    }
                }
            }

            if (thumbItem == null)
            {
                thumbItem = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Thumb));
            }

            if (thumbItem != null)
            {
                info.ThumbImageTag = GetImageCacheTag(thumbItem, ImageType.Thumb);
                info.ThumbItemId = GetDtoId(thumbItem);
            }

            if (thumbItem != null)
            {
                info.BackdropImageTag = GetImageCacheTag(backropItem, ImageType.Backdrop);
                info.BackdropItemId = GetDtoId(backropItem);
            }

            return info;
        }