コード例 #1
0
        private ImageInfo GetImageInfo(IHasImages item, ItemImageInfo info, int?imageIndex)
        {
            try
            {
                var fileInfo = new FileInfo(info.Path);

                var size = _imageProcessor.GetImageSize(info.Path);

                return(new ImageInfo
                {
                    Path = info.Path,
                    ImageIndex = imageIndex,
                    ImageType = info.Type,
                    ImageTag = _imageProcessor.GetImageCacheTag(item, info),
                    Size = fileInfo.Length,
                    Width = Convert.ToInt32(size.Width),
                    Height = Convert.ToInt32(size.Height)
                });
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Error getting image information for {0}", ex, info.Path);

                return(null);
            }
        }
コード例 #2
0
ファイル: SyncManager.cs プロジェクト: wilhil/MediaBrowser
        private async Task FillMetadata(SyncJob job)
        {
            var item = job.RequestedItemIds
                       .Select(_libraryManager.GetItemById)
                       .FirstOrDefault(i => i != null);

            if (item == null)
            {
                var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder());

                var user = _userManager.GetUserById(job.UserId);

                item = (await processor
                        .GetItemsForSync(job.Category, job.ParentId, job.RequestedItemIds, user, job.UnwatchedOnly).ConfigureAwait(false))
                       .FirstOrDefault();
            }

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

                var hasAlbumArtist = item as IHasAlbumArtist;
                if (hasAlbumArtist != null)
                {
                    job.ParentName = hasAlbumArtist.AlbumArtists.FirstOrDefault();
                }

                var primaryImage  = item.GetImageInfo(ImageType.Primary, 0);
                var itemWithImage = item;

                if (primaryImage == null)
                {
                    var parentWithImage = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Primary));

                    if (parentWithImage != null)
                    {
                        itemWithImage = parentWithImage;
                        primaryImage  = parentWithImage.GetImageInfo(ImageType.Primary, 0);
                    }
                }

                if (primaryImage != null)
                {
                    try
                    {
                        job.PrimaryImageTag    = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Primary);
                        job.PrimaryImageItemId = itemWithImage.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                        _logger.ErrorException("Error getting image info", ex);
                    }
                }
            }
        }
コード例 #3
0
ファイル: DtoService.cs プロジェクト: zindsia/jellyfin
 private string GetImageCacheTag(BaseItem item, ImageType type)
 {
     try
     {
         return(_imageProcessor.GetImageCacheTag(item, type));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error getting {type} image info", type);
         return(null);
     }
 }
コード例 #4
0
ファイル: DtoService.cs プロジェクト: ErniepDev/MediaBrowser
 private Guid?GetImageCacheTag(BaseItem item, ImageType type)
 {
     try
     {
         return(_imageProcessor.GetImageCacheTag(item, type));
     }
     catch (IOException ex)
     {
         _logger.ErrorException("Error getting {0} image info", ex, type);
         return(null);
     }
 }
コード例 #5
0
        private ItemStub GetItemStub(BaseItem item, ImageType imageType)
        {
            var stub = new ItemStub
            {
                Id        = _dtoService.GetDtoId(item),
                Name      = item.Name,
                ImageType = imageType
            };

            try
            {
                var tag = _imageProcessor.GetImageCacheTag(item, imageType);

                if (tag != null)
                {
                    stub.ImageTag = tag;
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error getting image tag for {0}", ex, item.Path);
                return(null);
            }

            return(stub);
        }
コード例 #6
0
ファイル: SyncManager.cs プロジェクト: mckartha/MediaBrowser
        private void FillMetadata(SyncJob job)
        {
            var item = GetItemsForSync(job.RequestedItemIds)
                       .FirstOrDefault();

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

                var hasAlbumArtist = item as IHasAlbumArtist;
                if (hasAlbumArtist != null)
                {
                    job.ParentName = hasAlbumArtist.AlbumArtists.FirstOrDefault();
                }

                var primaryImage = item.GetImageInfo(ImageType.Primary, 0);

                if (primaryImage != null)
                {
                    try
                    {
                        job.PrimaryImageTag    = _imageProcessor.GetImageCacheTag(item, ImageType.Primary);
                        job.PrimaryImageItemId = item.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                        _logger.ErrorException("Error getting image info", ex);
                    }
                }
            }
        }
コード例 #7
0
        private ImageDownloadInfo GetImageInfo(BaseItem item, ImageType type)
        {
            var    imageInfo = item.GetImageInfo(type, 0);
            string tag       = null;

            try
            {
                tag = _imageProcessor.GetImageCacheTag(item, type);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error getting image cache tag");
            }

            int?width  = imageInfo.Width;
            int?height = imageInfo.Height;

            if (width == 0 || height == 0)
            {
                //_imageProcessor.GetImageSize(item, imageInfo);
                width  = null;
                height = null;
            }

            else if (width == -1 || height == -1)
            {
                width  = null;
                height = null;
            }

            //try
            //{
            //    var size = _imageProcessor.GetImageSize(imageInfo);

            //    width = size.Width;
            //    height = size.Height;
            //}
            //catch
            //{

            //}

            var inputFormat = (Path.GetExtension(imageInfo.Path) ?? string.Empty)
                              .TrimStart('.')
                              .Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase);

            return(new ImageDownloadInfo
            {
                ItemId = item.Id,
                Type = type,
                ImageTag = tag,
                Width = width,
                Height = height,
                Format = inputFormat,
                ItemImageInfo = imageInfo
            });
        }
コード例 #8
0
ファイル: ImageService.cs プロジェクト: webcris77/Emby
        private ImageInfo GetImageInfo(IHasImages item, ItemImageInfo info, int?imageIndex)
        {
            try
            {
                int? width  = null;
                int? height = null;
                long length = 0;

                try
                {
                    if (info.IsLocalFile)
                    {
                        var fileInfo = new FileInfo(info.Path);
                        length = fileInfo.Length;

                        var size = _imageProcessor.GetImageSize(info);

                        width  = Convert.ToInt32(size.Width);
                        height = Convert.ToInt32(size.Height);
                    }
                }
                catch
                {
                }
                return(new ImageInfo
                {
                    Path = info.Path,
                    ImageIndex = imageIndex,
                    ImageType = info.Type,
                    ImageTag = _imageProcessor.GetImageCacheTag(item, info),
                    Size = length,
                    Width = width,
                    Height = height
                });
            }
            catch (Exception ex)
            {
                Logger.ErrorException("Error getting image information for {0}", ex, info.Path);

                return(null);
            }
        }
コード例 #9
0
        public static string GetImageCacheTag(this IImageProcessor processor, BaseItem item, ImageType imageType, int imageIndex)
        {
            var imageInfo = item.GetImageInfo(imageType, imageIndex);

            if (imageInfo == null)
            {
                return(null);
            }

            return(processor.GetImageCacheTag(item, imageInfo));
        }
コード例 #10
0
        public static Guid?GetImageCacheTag(this IImageProcessor processor, IHasImages item, ImageType imageType, int imageIndex)
        {
            var imageInfo = item.GetImageInfo(imageType, imageIndex);

            if (imageInfo == null)
            {
                return(null);
            }

            return(processor.GetImageCacheTag(item, imageInfo));
        }
コード例 #11
0
 private string GetImageCacheTag(BaseItem item, ItemImageInfo image)
 {
     try
     {
         return(_imageProcessor.GetImageCacheTag(item, image));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error getting {imageType} image info for {path}", image.Type, image.Path);
         return(null);
     }
 }
コード例 #12
0
        private Guid?GetImageTag(IHasImages info)
        {
            try
            {
                return(_imageProcessor.GetImageCacheTag(info, ImageType.Primary));
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error getting image info for {0}", ex, info.Name);
            }

            return(null);
        }
コード例 #13
0
        private ImageInfo GetImageInfo(BaseItem item, ItemImageInfo info, int? imageIndex)
        {
            int? width = null;
            int? height = null;
            string blurhash = null;
            long length = 0;

            try
            {
                if (info.IsLocalFile)
                {
                    var fileInfo = _fileSystem.GetFileInfo(info.Path);
                    length = fileInfo.Length;

                    blurhash = info.BlurHash;
                    width = info.Width;
                    height = info.Height;

                    if (width <= 0 || height <= 0)
                    {
                        width = null;
                        height = null;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Error getting image information for {Item}", item.Name);
            }

            try
            {
                return new ImageInfo
                {
                    Path = info.Path,
                    ImageIndex = imageIndex,
                    ImageType = info.Type,
                    ImageTag = _imageProcessor.GetImageCacheTag(item, info),
                    Size = length,
                    BlurHash = blurhash,
                    Width = width,
                    Height = height
                };
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Error getting image information for {Path}", info.Path);

                return null;
            }
        }
コード例 #14
0
ファイル: ImageService.cs プロジェクト: xbl3/jellyfin
        private ImageInfo GetImageInfo(BaseItem item, ItemImageInfo info, int?imageIndex)
        {
            int? width  = null;
            int? height = null;
            long length = 0;

            try
            {
                if (info.IsLocalFile)
                {
                    var fileInfo = _fileSystem.GetFileInfo(info.Path);
                    length = fileInfo.Length;

                    ImageDimensions size = _imageProcessor.GetImageDimensions(item, info);
                    _libraryManager.UpdateImages(item);
                    width  = size.Width;
                    height = size.Height;

                    if (width <= 0 || height <= 0)
                    {
                        width  = null;
                        height = null;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Error getting image information for {Item}", item.Name);
            }

            try
            {
                return(new ImageInfo
                {
                    Path = info.Path,
                    ImageIndex = imageIndex,
                    ImageType = info.Type,
                    ImageTag = _imageProcessor.GetImageCacheTag(item, info),
                    Size = length,
                    Width = width,
                    Height = height
                });
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Error getting image information for {Path}", info.Path);

                return(null);
            }
        }
コード例 #15
0
        public UserDto GetUserDto(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            var dto = new UserDto
            {
                Id               = user.Id.ToString("N"),
                Name             = user.Name,
                HasPassword      = !String.IsNullOrEmpty(user.Password),
                LastActivityDate = user.LastActivityDate,
                LastLoginDate    = user.LastLoginDate,
                Configuration    = user.Configuration
            };

            var image = user.PrimaryImagePath;

            if (!string.IsNullOrEmpty(image))
            {
                dto.PrimaryImageTag = _imageProcessor.GetImageCacheTag(user, ImageType.Primary, image);

                try
                {
                    AttachPrimaryImageAspectRatio(dto, user);
                }
                catch (Exception ex)
                {
                    // Have to use a catch-all unfortunately because some .net image methods throw plain Exceptions
                    _logger.ErrorException("Error generating PrimaryImageAspectRatio for {0}", ex, user.Name);
                }
            }

            return(dto);
        }
コード例 #16
0
ファイル: ImageService.cs プロジェクト: sxryt/jellyfin
        private ImageInfo GetImageInfo(BaseItem item, ItemImageInfo info, int?imageIndex)
        {
            try
            {
                int? width  = null;
                int? height = null;
                long length = 0;

                try
                {
                    if (info.IsLocalFile)
                    {
                        var fileInfo = _fileSystem.GetFileInfo(info.Path);
                        length = fileInfo.Length;

                        var size = _imageProcessor.GetImageSize(item, info, true, true);

                        width  = Convert.ToInt32(size.Width);
                        height = Convert.ToInt32(size.Height);

                        if (width <= 0 || height <= 0)
                        {
                            width  = null;
                            height = null;
                        }
                    }
                }
                catch
                {
                }
                return(new ImageInfo
                {
                    Path = info.Path,
                    ImageIndex = imageIndex,
                    ImageType = info.Type,
                    ImageTag = _imageProcessor.GetImageCacheTag(item, info),
                    Size = length,
                    Width = width,
                    Height = height
                });
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Error getting image information for {path}", info.Path);

                return(null);
            }
        }
コード例 #17
0
ファイル: DidlBuilder.cs プロジェクト: thirunjuguna/emby
        private ImageDownloadInfo GetImageInfo(BaseItem item, ImageType type)
        {
            var    imageInfo = item.GetImageInfo(type, 0);
            string tag       = null;

            try
            {
                tag = _imageProcessor.GetImageCacheTag(item, type);
            }
            catch
            {
            }

            int?width  = null;
            int?height = null;

            //try
            //{
            //    var size = _imageProcessor.GetImageSize(imageInfo);

            //    width = Convert.ToInt32(size.Width);
            //    height = Convert.ToInt32(size.Height);
            //}
            //catch
            //{

            //}

            var inputFormat = (Path.GetExtension(imageInfo.Path) ?? string.Empty)
                              .TrimStart('.')
                              .Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase);

            return(new ImageDownloadInfo
            {
                ItemId = item.Id.ToString("N"),
                Type = type,
                ImageTag = tag,
                Width = width,
                Height = height,
                Format = inputFormat,
                ItemImageInfo = imageInfo
            });
        }
コード例 #18
0
ファイル: DidlBuilder.cs プロジェクト: mcanthony/Emby
        private ImageDownloadInfo GetImageInfo(BaseItem item, ImageType type)
        {
            var    imageInfo = item.GetImageInfo(type, 0);
            string tag       = null;

            try
            {
                tag = _imageProcessor.GetImageCacheTag(item, type);
            }
            catch
            {
            }

            int?width  = null;
            int?height = null;

            //try
            //{
            //    var size = _imageProcessor.GetImageSize(imageInfo);

            //    width = Convert.ToInt32(size.Width);
            //    height = Convert.ToInt32(size.Height);
            //}
            //catch
            //{

            //}

            return(new ImageDownloadInfo
            {
                ItemId = item.Id.ToString("N"),
                Type = type,
                ImageTag = tag,
                Width = width,
                Height = height,
                File = imageInfo.Path,
                ItemImageInfo = imageInfo
            });
        }
コード例 #19
0
        private ImageDownloadInfo GetImageInfo(BaseItem item, ImageType type)
        {
            var    imageInfo = item.GetImageInfo(type, 0);
            string tag       = null;

            try
            {
                var guid = _imageProcessor.GetImageCacheTag(item, ImageType.Primary);

                tag = guid.HasValue ? guid.Value.ToString("N") : null;
            }
            catch
            {
            }

            int?width  = null;
            int?height = null;

            try
            {
                var size = _imageProcessor.GetImageSize(imageInfo.Path, imageInfo.DateModified);

                width  = Convert.ToInt32(size.Width);
                height = Convert.ToInt32(size.Height);
            }
            catch
            {
            }

            return(new ImageDownloadInfo
            {
                ItemId = item.Id.ToString("N"),
                Type = ImageType.Primary,
                ImageTag = tag,
                Width = width,
                Height = height
            });
        }
コード例 #20
0
        /// <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);
        }
コード例 #21
0
        private void FillImages(BaseItemDto dto, string seriesName, string programSeriesId)
        {
            var librarySeries = _libraryManager.GetItemList(new InternalItemsQuery
            {
                IncludeItemTypes = new string[] { typeof(Series).Name },
                Name             = seriesName,
                Limit            = 1,
                ImageTypes       = new ImageType[] { ImageType.Thumb },
                DtoOptions       = new DtoOptions(false)
            }).FirstOrDefault();

            if (librarySeries != null)
            {
                var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
                if (image != null)
                {
                    try
                    {
                        dto.ParentThumbImageTag = _imageProcessor.GetImageCacheTag(librarySeries, image);
                        dto.ParentThumbItemId   = librarySeries.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Error");
                    }
                }
                image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
                if (image != null)
                {
                    try
                    {
                        dto.ParentBackdropImageTags = new string[]
                        {
                            _imageProcessor.GetImageCacheTag(librarySeries, image)
                        };
                        dto.ParentBackdropItemId = librarySeries.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Error");
                    }
                }
            }

            var program = _libraryManager.GetItemList(new InternalItemsQuery
            {
                IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name },
                ExternalSeriesId = programSeriesId,
                Limit            = 1,
                ImageTypes       = new ImageType[] { ImageType.Primary },
                DtoOptions       = new DtoOptions(false),
                Name             = string.IsNullOrEmpty(programSeriesId) ? seriesName : null
            }).FirstOrDefault();

            if (program != null)
            {
                var image = program.GetImageInfo(ImageType.Primary, 0);
                if (image != null)
                {
                    try
                    {
                        dto.ParentPrimaryImageTag    = _imageProcessor.GetImageCacheTag(program, image);
                        dto.ParentPrimaryImageItemId = program.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Error");
                    }
                }

                if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0)
                {
                    image = program.GetImageInfo(ImageType.Backdrop, 0);
                    if (image != null)
                    {
                        try
                        {
                            dto.ParentBackdropImageTags = new string[]
                            {
                                _imageProcessor.GetImageCacheTag(program, image)
                            };
                            dto.ParentBackdropItemId = program.Id.ToString("N");
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError(ex, "Error");
                        }
                    }
                }
            }
        }
コード例 #22
0
 public static string GetImageCacheTag(this IImageProcessor processor, IHasMetadata item, ImageType imageType)
 {
     return(processor.GetImageCacheTag(item, imageType, 0));
 }
コード例 #23
0
        private void FillImages(BaseItemDto dto, string seriesName, string programSeriesId)
        {
            var librarySeries = _libraryManager.GetItemList(new InternalItemsQuery
            {
                IncludeItemTypes = new string[] { typeof(Series).Name },
                Name             = seriesName,
                Limit            = 1,
                ImageTypes       = new ImageType[] { ImageType.Thumb },
                DtoOptions       = new DtoOptions
                {
                    Fields = new List <MediaBrowser.Model.Querying.ItemFields>()
                }
            }).FirstOrDefault();

            if (librarySeries != null)
            {
                var image = librarySeries.GetImageInfo(ImageType.Thumb, 0);
                if (image != null)
                {
                    try
                    {
                        dto.ParentThumbImageTag = _imageProcessor.GetImageCacheTag(librarySeries, image);
                        dto.ParentThumbItemId   = librarySeries.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                    }
                }
                image = librarySeries.GetImageInfo(ImageType.Backdrop, 0);
                if (image != null)
                {
                    try
                    {
                        dto.ParentBackdropImageTags = new List <string>
                        {
                            _imageProcessor.GetImageCacheTag(librarySeries, image)
                        };
                        dto.ParentBackdropItemId = librarySeries.Id.ToString("N");
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(programSeriesId))
            {
                var program = _libraryManager.GetItemList(new InternalItemsQuery
                {
                    IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name },
                    ExternalSeriesId = programSeriesId,
                    Limit            = 1,
                    ImageTypes       = new ImageType[] { ImageType.Primary },
                    DtoOptions       = new DtoOptions
                    {
                        Fields = new List <MediaBrowser.Model.Querying.ItemFields>()
                    }
                }).FirstOrDefault();

                if (program != null)
                {
                    var image = program.GetImageInfo(ImageType.Primary, 0);
                    if (image != null)
                    {
                        try
                        {
                            dto.ParentPrimaryImageTag    = _imageProcessor.GetImageCacheTag(program, image);
                            dto.ParentPrimaryImageItemId = program.Id.ToString("N");
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Count == 0)
                    {
                        image = program.GetImageInfo(ImageType.Backdrop, 0);
                        if (image != null)
                        {
                            try
                            {
                                dto.ParentBackdropImageTags = new List <string>
                                {
                                    _imageProcessor.GetImageCacheTag(program, image)
                                };
                                dto.ParentBackdropItemId = program.Id.ToString("N");
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                }
            }
        }
コード例 #24
0
        /// <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);
        }
コード例 #25
0
 public static string GetImageCacheTag(this IImageProcessor processor, BaseItem item, ImageType imageType)
 {
     return(processor.GetImageCacheTag(item, imageType, 0));
 }
コード例 #26
0
        /// <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);
        }
コード例 #27
0
        /// <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);
        }
コード例 #28
0
ファイル: LiveTvDtoService.cs プロジェクト: terabyte128/Emby
        public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvService service, string channelName)
        {
            var dto = new SeriesTimerInfoDto
            {
                Id                    = GetInternalSeriesTimerId(service.Name, info.Id).ToString("N"),
                Overview              = info.Overview,
                EndDate               = info.EndDate,
                Name                  = info.Name,
                StartDate             = info.StartDate,
                ExternalId            = info.Id,
                PrePaddingSeconds     = info.PrePaddingSeconds,
                PostPaddingSeconds    = info.PostPaddingSeconds,
                IsPostPaddingRequired = info.IsPostPaddingRequired,
                IsPrePaddingRequired  = info.IsPrePaddingRequired,
                Days                  = info.Days,
                Priority              = info.Priority,
                RecordAnyChannel      = info.RecordAnyChannel,
                RecordAnyTime         = info.RecordAnyTime,
                SkipEpisodesInLibrary = info.SkipEpisodesInLibrary,
                KeepUpTo              = info.KeepUpTo,
                KeepUntil             = info.KeepUntil,
                RecordNewOnly         = info.RecordNewOnly,
                ExternalChannelId     = info.ChannelId,
                ExternalProgramId     = info.ProgramId,
                ServiceName           = service.Name,
                ChannelName           = channelName,
                ServerId              = _appHost.SystemId
            };

            if (!string.IsNullOrEmpty(info.ChannelId))
            {
                dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N");
            }

            if (!string.IsNullOrEmpty(info.ProgramId))
            {
                dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N");
            }

            dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days);

            if (!string.IsNullOrWhiteSpace(info.SeriesId))
            {
                var program = _libraryManager.GetItemList(new InternalItemsQuery
                {
                    IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name },
                    ExternalSeriesId = info.SeriesId,
                    Limit            = 1,
                    ImageTypes       = new ImageType[] { ImageType.Primary }
                }).FirstOrDefault();

                if (program != null)
                {
                    var image = program.GetImageInfo(ImageType.Primary, 0);
                    if (image != null)
                    {
                        try
                        {
                            dto.ParentPrimaryImageTag    = _imageProcessor.GetImageCacheTag(program, image);
                            dto.ParentPrimaryImageItemId = program.Id.ToString("N");
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }

            return(dto);
        }
コード例 #29
0
ファイル: UserManager.cs プロジェクト: zhoucheng8023/jellyfin
        public UserDto GetUserDto(User user, string?remoteEndPoint = null)
        {
            var hasPassword = GetAuthenticationProvider(user).HasPassword(user);

            return(new UserDto
            {
                Name = user.Username,
                Id = user.Id,
                ServerId = _appHost.SystemId,
                HasPassword = hasPassword,
                HasConfiguredPassword = hasPassword,
                HasConfiguredEasyPassword = !string.IsNullOrEmpty(user.EasyPassword),
                EnableAutoLogin = user.EnableAutoLogin,
                LastLoginDate = user.LastLoginDate,
                LastActivityDate = user.LastActivityDate,
                PrimaryImageTag = user.ProfileImage != null?_imageProcessor.GetImageCacheTag(user) : null,
                                      Configuration = new UserConfiguration
                {
                    SubtitleMode = user.SubtitleMode,
                    HidePlayedInLatest = user.HidePlayedInLatest,
                    EnableLocalPassword = user.EnableLocalPassword,
                    PlayDefaultAudioTrack = user.PlayDefaultAudioTrack,
                    DisplayCollectionsView = user.DisplayCollectionsView,
                    DisplayMissingEpisodes = user.DisplayMissingEpisodes,
                    AudioLanguagePreference = user.AudioLanguagePreference,
                    RememberAudioSelections = user.RememberAudioSelections,
                    EnableNextEpisodeAutoPlay = user.EnableNextEpisodeAutoPlay,
                    RememberSubtitleSelections = user.RememberSubtitleSelections,
                    SubtitleLanguagePreference = user.SubtitleLanguagePreference ?? string.Empty,
                    OrderedViews = user.GetPreference(PreferenceKind.OrderedViews),
                    GroupedFolders = user.GetPreference(PreferenceKind.GroupedFolders),
                    MyMediaExcludes = user.GetPreference(PreferenceKind.MyMediaExcludes),
                    LatestItemsExcludes = user.GetPreference(PreferenceKind.LatestItemExcludes)
                },
                Policy = new UserPolicy
                {
                    MaxParentalRating = user.MaxParentalAgeRating,
                    EnableUserPreferenceAccess = user.EnableUserPreferenceAccess,
                    RemoteClientBitrateLimit = user.RemoteClientBitrateLimit ?? 0,
                    AuthenticationProviderId = user.AuthenticationProviderId,
                    PasswordResetProviderId = user.PasswordResetProviderId,
                    InvalidLoginAttemptCount = user.InvalidLoginAttemptCount,
                    LoginAttemptsBeforeLockout = user.LoginAttemptsBeforeLockout ?? -1,
                    IsAdministrator = user.HasPermission(PermissionKind.IsAdministrator),
                    IsHidden = user.HasPermission(PermissionKind.IsHidden),
                    IsDisabled = user.HasPermission(PermissionKind.IsDisabled),
                    EnableSharedDeviceControl = user.HasPermission(PermissionKind.EnableSharedDeviceControl),
                    EnableRemoteAccess = user.HasPermission(PermissionKind.EnableRemoteAccess),
                    EnableLiveTvManagement = user.HasPermission(PermissionKind.EnableLiveTvManagement),
                    EnableLiveTvAccess = user.HasPermission(PermissionKind.EnableLiveTvAccess),
                    EnableMediaPlayback = user.HasPermission(PermissionKind.EnableMediaPlayback),
                    EnableAudioPlaybackTranscoding = user.HasPermission(PermissionKind.EnableAudioPlaybackTranscoding),
                    EnableVideoPlaybackTranscoding = user.HasPermission(PermissionKind.EnableVideoPlaybackTranscoding),
                    EnableContentDeletion = user.HasPermission(PermissionKind.EnableContentDeletion),
                    EnableContentDownloading = user.HasPermission(PermissionKind.EnableContentDownloading),
                    EnableSyncTranscoding = user.HasPermission(PermissionKind.EnableSyncTranscoding),
                    EnableMediaConversion = user.HasPermission(PermissionKind.EnableMediaConversion),
                    EnableAllChannels = user.HasPermission(PermissionKind.EnableAllChannels),
                    EnableAllDevices = user.HasPermission(PermissionKind.EnableAllDevices),
                    EnableAllFolders = user.HasPermission(PermissionKind.EnableAllFolders),
                    EnableRemoteControlOfOtherUsers = user.HasPermission(PermissionKind.EnableRemoteControlOfOtherUsers),
                    EnablePlaybackRemuxing = user.HasPermission(PermissionKind.EnablePlaybackRemuxing),
                    ForceRemoteSourceTranscoding = user.HasPermission(PermissionKind.ForceRemoteSourceTranscoding),
                    EnablePublicSharing = user.HasPermission(PermissionKind.EnablePublicSharing),
                    AccessSchedules = user.AccessSchedules.ToArray(),
                    BlockedTags = user.GetPreference(PreferenceKind.BlockedTags),
                    EnabledChannels = user.GetPreference(PreferenceKind.EnabledChannels),
                    EnabledDevices = user.GetPreference(PreferenceKind.EnabledDevices),
                    EnabledFolders = user.GetPreference(PreferenceKind.EnabledFolders),
                    EnableContentDeletionFromFolders = user.GetPreference(PreferenceKind.EnableContentDeletionFromFolders),
                    SyncPlayAccess = user.SyncPlayAccess,
                    BlockedChannels = user.GetPreference(PreferenceKind.BlockedChannels),
                    BlockedMediaFolders = user.GetPreference(PreferenceKind.BlockedMediaFolders),
                    BlockUnratedItems = user.GetPreference(PreferenceKind.BlockUnratedItems).Select(Enum.Parse <UnratedItem>).ToArray()
                }
            });
        }
コード例 #30
0
        /// <summary>
        /// Gets the item image infos.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Task{List{ImageInfo}}.</returns>
        public List <ImageInfo> GetItemImageInfos(BaseItem item)
        {
            var list = new List <ImageInfo>();

            foreach (var image in item.Images)
            {
                var path = image.Value;

                var fileInfo = new FileInfo(path);

                var size = _imageProcessor.GetImageSize(path);

                list.Add(new ImageInfo
                {
                    Path      = path,
                    ImageType = image.Key,
                    ImageTag  = _imageProcessor.GetImageCacheTag(item, image.Key, path),
                    Size      = fileInfo.Length,
                    Width     = Convert.ToInt32(size.Width),
                    Height    = Convert.ToInt32(size.Height)
                });
            }

            var index = 0;

            foreach (var image in item.BackdropImagePaths)
            {
                var fileInfo = new FileInfo(image);

                var size = _imageProcessor.GetImageSize(image);

                list.Add(new ImageInfo
                {
                    Path       = image,
                    ImageIndex = index,
                    ImageType  = ImageType.Backdrop,
                    ImageTag   = _imageProcessor.GetImageCacheTag(item, ImageType.Backdrop, image),
                    Size       = fileInfo.Length,
                    Width      = Convert.ToInt32(size.Width),
                    Height     = Convert.ToInt32(size.Height)
                });

                index++;
            }

            index = 0;

            foreach (var image in item.ScreenshotImagePaths)
            {
                var fileInfo = new FileInfo(image);

                var size = _imageProcessor.GetImageSize(image);

                list.Add(new ImageInfo
                {
                    Path       = image,
                    ImageIndex = index,
                    ImageType  = ImageType.Screenshot,
                    ImageTag   = _imageProcessor.GetImageCacheTag(item, ImageType.Screenshot, image),
                    Size       = fileInfo.Length,
                    Width      = Convert.ToInt32(size.Width),
                    Height     = Convert.ToInt32(size.Height)
                });

                index++;
            }

            var video = item as Video;

            if (video != null)
            {
                index = 0;

                foreach (var chapter in _itemRepo.GetChapters(video.Id))
                {
                    if (!string.IsNullOrEmpty(chapter.ImagePath))
                    {
                        var image = chapter.ImagePath;

                        var fileInfo = new FileInfo(image);

                        var size = _imageProcessor.GetImageSize(image);

                        list.Add(new ImageInfo
                        {
                            Path       = image,
                            ImageIndex = index,
                            ImageType  = ImageType.Chapter,
                            ImageTag   = _imageProcessor.GetImageCacheTag(item, ImageType.Chapter, image),
                            Size       = fileInfo.Length,
                            Width      = Convert.ToInt32(size.Width),
                            Height     = Convert.ToInt32(size.Height)
                        });
                    }

                    index++;
                }
            }

            return(list);
        }