grab image sizes at discovery time

This commit is contained in:
Luke Pulverenti
2014-10-12 11:18:26 -04:00
parent 47915df62c
commit 69b83082c8
11 changed files with 112 additions and 105 deletions

View File

@@ -372,7 +372,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.Longitude = item.Longitude;
dto.Altitude = item.Altitude;
dto.IsoSpeedRating = item.IsoSpeedRating;
var album = item.Album;
if (album != null)
@@ -659,7 +659,7 @@ namespace MediaBrowser.Server.Implementations.Dto
/// <param name="chapterInfo">The chapter info.</param>
/// <param name="item">The item.</param>
/// <returns>ChapterInfoDto.</returns>
public ChapterInfoDto GetChapterInfoDto(ChapterInfo chapterInfo, BaseItem item)
private ChapterInfoDto GetChapterInfoDto(ChapterInfo chapterInfo, BaseItem item)
{
var dto = new ChapterInfoDto
{
@@ -680,6 +680,13 @@ namespace MediaBrowser.Server.Implementations.Dto
return dto;
}
public List<ChapterInfoDto> GetChapterInfoDtos(BaseItem item)
{
return _itemRepo.GetChapters(item.Id)
.Select(c => GetChapterInfoDto(c, item))
.ToList();
}
/// <summary>
/// Sets simple property values on a DTOBaseItem
/// </summary>
@@ -1055,20 +1062,7 @@ namespace MediaBrowser.Server.Implementations.Dto
if (fields.Contains(ItemFields.Chapters))
{
List<ChapterInfoDto> chapters;
if (dto.MediaSources != null && dto.MediaSources.Count > 0)
{
chapters = _itemRepo.GetChapters(item.Id).Select(c => GetChapterInfoDto(c, item)).ToList();
}
else
{
chapters = _itemRepo.GetChapters(video.Id)
.Select(c => GetChapterInfoDto(c, item))
.ToList();
}
dto.Chapters = chapters;
dto.Chapters = GetChapterInfoDtos(item);
}
}
@@ -1435,21 +1429,35 @@ namespace MediaBrowser.Server.Implementations.Dto
// See if we can avoid a file system lookup by looking for the file in ResolveArgs
var dateModified = imageInfo.DateModified;
double? width = imageInfo.Width;
double? height = imageInfo.Height;
ImageSize size;
try
if (!width.HasValue || !height.HasValue)
{
size = _imageProcessor.GetImageSize(path, dateModified);
try
{
size = _imageProcessor.GetImageSize(path, dateModified);
}
catch (FileNotFoundException)
{
_logger.Error("Image file does not exist: {0}", path);
return;
}
catch (Exception ex)
{
_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
return;
}
}
catch (FileNotFoundException)
else
{
_logger.Error("Image file does not exist: {0}", path);
return;
}
catch (Exception ex)
{
_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
return;
size = new ImageSize
{
Height = height.Value,
Width = width.Value
};
}
dto.OriginalPrimaryImageAspectRatio = size.Width / size.Height;

View File

@@ -1224,6 +1224,6 @@
"MessageNoDevicesSupportCameraUpload": "You currently don't have any devices that support camera upload.",
"LabelCameraUploadPath": "Camera upload path:",
"LabelCameraUploadPathHelp": "Select a custom upload path, if desired. If unspecified a default folder will be used.",
"LabelCreateCameraUploadSubfolder": "Create a sub-folder for each device",
"LabelCreateCameraUploadSubfolderHelp": "Specific folders can be assigned to devices by clicking on the device on the Devices page."
"LabelCreateCameraUploadSubfolder": "Create a subfolder for each device",
"LabelCreateCameraUploadSubfolderHelp": "Specific folders can be assigned to a device by clicking on it from the Devices page."
}

View File

@@ -26,7 +26,6 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -1594,7 +1593,7 @@ namespace MediaBrowser.Server.Implementations.Session
{
info.ChapterImagesItemId = chapterOwner.Id.ToString("N");
info.Chapters = _itemRepo.GetChapters(chapterOwner.Id).Select(i => _dtoService.GetChapterInfoDto(i, chapterOwner)).ToList();
info.Chapters = _dtoService.GetChapterInfoDtos(chapterOwner).ToList();
}
if (!string.IsNullOrWhiteSpace(mediaSourceId))