/// <summary> /// Gets the search hint result. /// </summary> /// <param name="hintInfo">The hint info.</param> /// <returns>SearchHintResult.</returns> private SearchHint GetSearchHintResult(SearchHintInfo hintInfo) { var item = hintInfo.Item; var result = new SearchHint { Name = item.Name, IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, ItemId = _dtoService.GetDtoId(item), Type = item.GetClientTypeName(), MediaType = item.MediaType, MatchedTerm = hintInfo.MatchedTerm, DisplayMediaType = item.DisplayMediaType, RunTimeTicks = item.RunTimeTicks, ProductionYear = item.ProductionYear }; var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary); if (primaryImageTag.HasValue) { result.PrimaryImageTag = primaryImageTag.Value; } SetThumbImageInfo(result, item); SetBackdropImageInfo(result, item); var episode = item as Episode; if (episode != null) { result.Series = episode.Series.Name; } var season = item as Season; if (season != null) { result.Series = season.Series.Name; result.EpisodeCount = season.GetRecursiveChildren(i => i is Episode).Count; } var series = item as Series; if (series != null) { result.EpisodeCount = series.GetRecursiveChildren(i => i is Episode).Count; } var album = item as MusicAlbum; if (album != null) { var songs = album.GetRecursiveChildren().OfType <Audio>().ToList(); result.SongCount = songs.Count; result.Artists = songs.SelectMany(i => i.AllArtists) .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray(); result.AlbumArtist = songs.Select(i => i.AlbumArtist).FirstOrDefault(i => !string.IsNullOrEmpty(i)); } var song = item as Audio; if (song != null) { result.Album = song.Album; result.AlbumArtist = song.AlbumArtist; result.Artists = song.Artists.ToArray(); } return(result); }
/// <summary> /// Gets the search hint result. /// </summary> /// <param name="hintInfo">The hint info.</param> /// <returns>SearchHintResult.</returns> private SearchHint GetSearchHintResult(SearchHintInfo hintInfo) { var item = hintInfo.Item; var result = new SearchHint { Name = item.Name, IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, ItemId = _dtoService.GetDtoId(item), Type = item.GetClientTypeName(), MediaType = item.MediaType, MatchedTerm = hintInfo.MatchedTerm, DisplayMediaType = item.DisplayMediaType, RunTimeTicks = item.RunTimeTicks, ProductionYear = item.ProductionYear }; result.ChannelId = item.ChannelId; var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary); if (primaryImageTag != null) { result.PrimaryImageTag = primaryImageTag; result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item); } SetThumbImageInfo(result, item); SetBackdropImageInfo(result, item); var hasSeries = item as IHasSeries; if (hasSeries != null) { result.Series = hasSeries.SeriesName; } var season = item as Season; if (season != null) { result.EpisodeCount = season.GetRecursiveChildren(i => i is Episode).Count; } var series = item as Series; if (series != null) { result.EpisodeCount = series.GetRecursiveChildren(i => i is Episode).Count; } var album = item as MusicAlbum; if (album != null) { result.SongCount = album.Tracks.Count(); result.Artists = album.Artists.ToArray(); result.AlbumArtist = album.AlbumArtist; } var song = item as Audio; if (song != null) { result.Album = song.Album; result.AlbumArtist = song.AlbumArtists.FirstOrDefault(); result.Artists = song.Artists.ToArray(); } if (!string.IsNullOrWhiteSpace(item.ChannelId)) { var channel = _libraryManager.GetItemById(item.ChannelId); result.ChannelName = channel == null ? null : channel.Name; } return(result); }
/// <summary> /// Gets the search hint result. /// </summary> /// <param name="hintInfo">The hint info.</param> /// <returns>SearchHintResult.</returns> private SearchHint GetSearchHintResult(SearchHintInfo hintInfo) { var item = hintInfo.Item; var result = new SearchHint { Name = item.Name, IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, Id = item.Id, Type = item.GetClientTypeName(), MediaType = item.MediaType, MatchedTerm = hintInfo.MatchedTerm, RunTimeTicks = item.RunTimeTicks, ProductionYear = item.ProductionYear, ChannelId = item.ChannelId, EndDate = item.EndDate }; // legacy result.ItemId = result.Id; if (item.IsFolder) { result.IsFolder = true; } var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary); if (primaryImageTag != null) { result.PrimaryImageTag = primaryImageTag; result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item); } SetThumbImageInfo(result, item); SetBackdropImageInfo(result, item); switch (item) { case IHasSeries hasSeries: result.Series = hasSeries.SeriesName; break; case LiveTvProgram program: result.StartDate = program.StartDate; break; case Series series: if (series.Status.HasValue) { result.Status = series.Status.Value.ToString(); } break; case MusicAlbum album: result.Artists = album.Artists; result.AlbumArtist = album.AlbumArtist; break; case Audio song: result.AlbumArtist = song.AlbumArtists?[0]; result.Artists = song.Artists; MusicAlbum musicAlbum = song.AlbumEntity; if (musicAlbum != null) { result.Album = musicAlbum.Name; result.AlbumId = musicAlbum.Id; } else { result.Album = song.Album; } break; } if (!item.ChannelId.Equals(Guid.Empty)) { var channel = _libraryManager.GetItemById(item.ChannelId); result.ChannelName = channel?.Name; } return(result); }
/// <summary> /// Gets the search hint result. /// </summary> /// <param name="hintInfo">The hint info.</param> /// <returns>SearchHintResult.</returns> private SearchHint GetSearchHintResult(SearchHintInfo hintInfo) { var item = hintInfo.Item; var result = new SearchHint { Name = item.Name, IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, Id = item.Id, Type = item.GetClientTypeName(), MediaType = item.MediaType, MatchedTerm = hintInfo.MatchedTerm, RunTimeTicks = item.RunTimeTicks, ProductionYear = item.ProductionYear, ChannelId = item.ChannelId, EndDate = item.EndDate }; // legacy result.ItemId = result.Id; if (item.IsFolder) { result.IsFolder = true; } var primaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary); if (primaryImageTag != null) { result.PrimaryImageTag = primaryImageTag; result.PrimaryImageAspectRatio = _dtoService.GetPrimaryImageAspectRatio(item); } SetThumbImageInfo(result, item); SetBackdropImageInfo(result, item); var program = item as LiveTvProgram; if (program != null) { result.StartDate = program.StartDate; } var hasSeries = item as IHasSeries; if (hasSeries != null) { result.Series = hasSeries.SeriesName; } var series = item as Series; if (series != null) { if (series.Status.HasValue) { result.Status = series.Status.Value.ToString(); } } var album = item as MusicAlbum; if (album != null) { result.Artists = album.Artists; result.AlbumArtist = album.AlbumArtist; } var song = item as Audio; if (song != null) { result.AlbumArtist = song.AlbumArtists.FirstOrDefault(); result.Artists = song.Artists; album = song.AlbumEntity; if (album != null) { result.Album = album.Name; result.AlbumId = album.Id; } else { result.Album = song.Album; } } if (!item.ChannelId.Equals(Guid.Empty)) { var channel = _libraryManager.GetItemById(item.ChannelId); result.ChannelName = channel == null ? null : channel.Name; } return(result); }
/// <summary> /// Gets the search hint result. /// </summary> /// <param name="hintInfo">The hint info.</param> /// <returns>SearchHintResult.</returns> private SearchHint GetSearchHintResult(SearchHintInfo hintInfo) { var item = hintInfo.Item; var result = new SearchHint { Name = item.Name, IndexNumber = item.IndexNumber, ParentIndexNumber = item.ParentIndexNumber, ItemId = DtoBuilder.GetClientItemId(item), Type = item.GetType().Name, MediaType = item.MediaType, MatchedTerm = hintInfo.MatchedTerm, DisplayMediaType = item.DisplayMediaType, RunTimeTicks = item.RunTimeTicks }; if (item.HasImage(ImageType.Primary)) { result.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, item.GetImage(ImageType.Primary)); } var episode = item as Episode; if (episode != null) { result.Series = episode.Series.Name; } var season = item as Season; if (season != null) { result.Series = season.Series.Name; result.EpisodeCount = season.RecursiveChildren.OfType <Episode>().Count(); } var series = item as Series; if (series != null) { result.EpisodeCount = series.RecursiveChildren.OfType <Episode>().Count(); } var album = item as MusicAlbum; if (album != null) { var songs = album.RecursiveChildren.OfType <Audio>().ToList(); result.SongCount = songs.Count; result.Artists = songs .Select(i => i.Artist) .Where(i => !string.IsNullOrEmpty(i)) .Distinct(StringComparer.OrdinalIgnoreCase) .ToArray(); result.AlbumArtist = songs.Select(i => i.AlbumArtist).FirstOrDefault(i => !string.IsNullOrEmpty(i)); } var song = item as Audio; if (song != null) { result.Album = song.Album; result.AlbumArtist = song.AlbumArtist; result.Artists = !string.IsNullOrEmpty(song.Artist) ? new[] { song.Artist } : new string[] { }; } return(result); }