grab image sizes at discovery time
This commit is contained in:
parent
47915df62c
commit
69b83082c8
|
@ -312,36 +312,6 @@ namespace MediaBrowser.Api.Images
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var video = item as Video;
|
|
||||||
|
|
||||||
if (video != null)
|
|
||||||
{
|
|
||||||
var index = 0;
|
|
||||||
|
|
||||||
foreach (var chapter in _itemRepo.GetChapters(video.Id))
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(chapter.ImagePath))
|
|
||||||
{
|
|
||||||
var image = chapter.ImagePath;
|
|
||||||
|
|
||||||
var info = GetImageInfo(item, new ItemImageInfo
|
|
||||||
{
|
|
||||||
Path = image,
|
|
||||||
Type = ImageType.Chapter,
|
|
||||||
DateModified = _fileSystem.GetLastWriteTimeUtc(image)
|
|
||||||
|
|
||||||
}, index);
|
|
||||||
|
|
||||||
if (info != null)
|
|
||||||
{
|
|
||||||
list.Add(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,8 +321,6 @@ namespace MediaBrowser.Api.Images
|
||||||
{
|
{
|
||||||
var fileInfo = new FileInfo(info.Path);
|
var fileInfo = new FileInfo(info.Path);
|
||||||
|
|
||||||
var size = _imageProcessor.GetImageSize(info.Path);
|
|
||||||
|
|
||||||
return new ImageInfo
|
return new ImageInfo
|
||||||
{
|
{
|
||||||
Path = info.Path,
|
Path = info.Path,
|
||||||
|
@ -360,8 +328,8 @@ namespace MediaBrowser.Api.Images
|
||||||
ImageType = info.Type,
|
ImageType = info.Type,
|
||||||
ImageTag = _imageProcessor.GetImageCacheTag(item, info),
|
ImageTag = _imageProcessor.GetImageCacheTag(item, info),
|
||||||
Size = fileInfo.Length,
|
Size = fileInfo.Length,
|
||||||
Width = Convert.ToInt32(size.Width),
|
Width = info.Width ?? 0,
|
||||||
Height = Convert.ToInt32(size.Height)
|
Height = info.Height ?? 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -47,10 +47,9 @@ namespace MediaBrowser.Controller.Dto
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the chapter information dto.
|
/// Gets the chapter information dto.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="chapterInfo">The chapter information.</param>
|
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <returns>ChapterInfoDto.</returns>
|
/// <returns>ChapterInfoDto.</returns>
|
||||||
ChapterInfoDto GetChapterInfoDto(ChapterInfo chapterInfo, BaseItem item);
|
List<ChapterInfoDto> GetChapterInfoDtos(BaseItem item);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the user item data dto.
|
/// Gets the user item data dto.
|
||||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
using MediaBrowser.Controller.Collections;
|
using MediaBrowser.Controller.Collections;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
|
@ -253,6 +254,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public static ILiveTvManager LiveTvManager { get; set; }
|
public static ILiveTvManager LiveTvManager { get; set; }
|
||||||
public static IChannelManager ChannelManager { get; set; }
|
public static IChannelManager ChannelManager { get; set; }
|
||||||
public static ICollectionManager CollectionManager { get; set; }
|
public static ICollectionManager CollectionManager { get; set; }
|
||||||
|
public static IImageProcessor ImageProcessor { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a <see cref="System.String" /> that represents this instance.
|
/// Returns a <see cref="System.String" /> that represents this instance.
|
||||||
|
@ -1455,17 +1457,16 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
if (image == null)
|
if (image == null)
|
||||||
{
|
{
|
||||||
ImageInfos.Add(new ItemImageInfo
|
ImageInfos.Add(GetImageInfo(file, type));
|
||||||
{
|
|
||||||
Path = file.FullName,
|
|
||||||
Type = type,
|
|
||||||
DateModified = FileSystem.GetLastWriteTimeUtc(file)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var imageInfo = GetImageInfo(file, type);
|
||||||
|
|
||||||
image.Path = file.FullName;
|
image.Path = file.FullName;
|
||||||
image.DateModified = FileSystem.GetLastWriteTimeUtc(file);
|
image.DateModified = imageInfo.DateModified;
|
||||||
|
image.Width = imageInfo.Width;
|
||||||
|
image.Height = imageInfo.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1574,7 +1575,9 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
Path = path,
|
Path = path,
|
||||||
DateModified = FileSystem.GetLastWriteTimeUtc(path),
|
DateModified = FileSystem.GetLastWriteTimeUtc(path),
|
||||||
Type = imageType
|
Type = imageType,
|
||||||
|
Width = chapter.ImageWidth,
|
||||||
|
Height = chapter.ImageHeight
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1631,16 +1634,35 @@ namespace MediaBrowser.Controller.Entities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageInfos.AddRange(newImageList.Select(i => new ItemImageInfo
|
ImageInfos.AddRange(newImageList.Select(i => GetImageInfo(i, imageType)));
|
||||||
{
|
|
||||||
Path = i.FullName,
|
|
||||||
Type = imageType,
|
|
||||||
DateModified = FileSystem.GetLastWriteTimeUtc(i)
|
|
||||||
}));
|
|
||||||
|
|
||||||
return newImageList.Count > 0;
|
return newImageList.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ItemImageInfo GetImageInfo(FileSystemInfo file, ImageType type)
|
||||||
|
{
|
||||||
|
var info = new ItemImageInfo
|
||||||
|
{
|
||||||
|
Path = file.FullName,
|
||||||
|
Type = type,
|
||||||
|
DateModified = FileSystem.GetLastWriteTimeUtc(file)
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var size = ImageProcessor.GetImageSize(info.Path);
|
||||||
|
|
||||||
|
info.Width = Convert.ToInt32(size.Width);
|
||||||
|
info.Height = Convert.ToInt32(size.Height);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the file system path to delete when the item is to be deleted
|
/// Gets the file system path to delete when the item is to be deleted
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -10,5 +10,9 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public ImageType Type { get; set; }
|
public ImageType Type { get; set; }
|
||||||
|
|
||||||
public DateTime DateModified { get; set; }
|
public DateTime DateModified { get; set; }
|
||||||
|
|
||||||
|
public int? Width { get; set; }
|
||||||
|
|
||||||
|
public int? Height { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -869,19 +869,22 @@ namespace MediaBrowser.Dlna.Didl
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int? width = null;
|
int? width = imageInfo.Width;
|
||||||
int? height = null;
|
int? height = imageInfo.Height;
|
||||||
|
|
||||||
try
|
if (!height.HasValue && !width.HasValue)
|
||||||
{
|
{
|
||||||
var size = _imageProcessor.GetImageSize(imageInfo.Path, imageInfo.DateModified);
|
try
|
||||||
|
{
|
||||||
|
var size = _imageProcessor.GetImageSize(imageInfo.Path, imageInfo.DateModified);
|
||||||
|
|
||||||
width = Convert.ToInt32(size.Width);
|
width = Convert.ToInt32(size.Width);
|
||||||
height = Convert.ToInt32(size.Height);
|
height = Convert.ToInt32(size.Height);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ImageDownloadInfo
|
return new ImageDownloadInfo
|
||||||
|
|
|
@ -23,5 +23,17 @@ namespace MediaBrowser.Model.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The image path.</value>
|
/// <value>The image path.</value>
|
||||||
public string ImagePath { get; set; }
|
public string ImagePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the height of the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The height of the image.</value>
|
||||||
|
public int? ImageHeight { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the width of the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The width of the image.</value>
|
||||||
|
public int? ImageWidth { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
@ -18,12 +17,10 @@ namespace MediaBrowser.Providers.Photos
|
||||||
public class PhotoProvider : ICustomMetadataProvider<Photo>, IHasItemChangeMonitor
|
public class PhotoProvider : ICustomMetadataProvider<Photo>, IHasItemChangeMonitor
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IImageProcessor _imageProcessor;
|
|
||||||
|
|
||||||
public PhotoProvider(ILogger logger, IImageProcessor imageProcessor)
|
public PhotoProvider(ILogger logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_imageProcessor = imageProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ItemUpdateType> FetchAsync(Photo item, MetadataRefreshOptions options, CancellationToken cancellationToken)
|
public Task<ItemUpdateType> FetchAsync(Photo item, MetadataRefreshOptions options, CancellationToken cancellationToken)
|
||||||
|
@ -142,9 +139,10 @@ namespace MediaBrowser.Providers.Photos
|
||||||
_logger.ErrorException("Image Provider - Error reading image tag for {0}", e, item.Path);
|
_logger.ErrorException("Image Provider - Error reading image tag for {0}", e, item.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = _imageProcessor.GetImageSize(item.Path);
|
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);
|
||||||
item.Height = Convert.ToInt32(size.Height);
|
|
||||||
item.Width = Convert.ToInt32(size.Width);
|
item.Height = imageInfo.Height;
|
||||||
|
item.Width = imageInfo.Width;
|
||||||
|
|
||||||
const ItemUpdateType result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;
|
const ItemUpdateType result = ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataImport;
|
||||||
return Task.FromResult(result);
|
return Task.FromResult(result);
|
||||||
|
|
|
@ -93,10 +93,10 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
var hasBadData = HasInvalidContent(group);
|
var hasBadData = HasInvalidContent(group);
|
||||||
|
|
||||||
var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(group, episodeLookup, hasBadData)
|
var anySeasonsRemoved = await RemoveObsoleteOrMissingSeasons(group, episodeLookup, false)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(group, episodeLookup, hasBadData)
|
var anyEpisodesRemoved = await RemoveObsoleteOrMissingEpisodes(group, episodeLookup, false)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var hasNewEpisodes = false;
|
var hasNewEpisodes = false;
|
||||||
|
@ -204,12 +204,6 @@ namespace MediaBrowser.Providers.TV
|
||||||
IEnumerable<Tuple<int, int>> episodeLookup,
|
IEnumerable<Tuple<int, int>> episodeLookup,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// Be conservative here to avoid creating missing episodes for ones they already have
|
|
||||||
if (!seriesHasBadData)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var existingEpisodes = (from s in series
|
var existingEpisodes = (from s in series
|
||||||
let seasonOffset = TvdbSeriesProvider.GetSeriesOffset(s.ProviderIds) ?? ((s.AnimeSeriesIndex ?? 1) - 1)
|
let seasonOffset = TvdbSeriesProvider.GetSeriesOffset(s.ProviderIds) ?? ((s.AnimeSeriesIndex ?? 1) - 1)
|
||||||
from c in s.RecursiveChildren.OfType<Episode>()
|
from c in s.RecursiveChildren.OfType<Episode>()
|
||||||
|
|
|
@ -659,7 +659,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
/// <param name="chapterInfo">The chapter info.</param>
|
/// <param name="chapterInfo">The chapter info.</param>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <returns>ChapterInfoDto.</returns>
|
/// <returns>ChapterInfoDto.</returns>
|
||||||
public ChapterInfoDto GetChapterInfoDto(ChapterInfo chapterInfo, BaseItem item)
|
private ChapterInfoDto GetChapterInfoDto(ChapterInfo chapterInfo, BaseItem item)
|
||||||
{
|
{
|
||||||
var dto = new ChapterInfoDto
|
var dto = new ChapterInfoDto
|
||||||
{
|
{
|
||||||
|
@ -680,6 +680,13 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ChapterInfoDto> GetChapterInfoDtos(BaseItem item)
|
||||||
|
{
|
||||||
|
return _itemRepo.GetChapters(item.Id)
|
||||||
|
.Select(c => GetChapterInfoDto(c, item))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets simple property values on a DTOBaseItem
|
/// Sets simple property values on a DTOBaseItem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1055,20 +1062,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.Chapters))
|
if (fields.Contains(ItemFields.Chapters))
|
||||||
{
|
{
|
||||||
List<ChapterInfoDto> chapters;
|
dto.Chapters = GetChapterInfoDtos(item);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
// See if we can avoid a file system lookup by looking for the file in ResolveArgs
|
||||||
var dateModified = imageInfo.DateModified;
|
var dateModified = imageInfo.DateModified;
|
||||||
|
|
||||||
|
double? width = imageInfo.Width;
|
||||||
|
double? height = imageInfo.Height;
|
||||||
|
|
||||||
ImageSize size;
|
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);
|
size = new ImageSize
|
||||||
return;
|
{
|
||||||
}
|
Height = height.Value,
|
||||||
catch (Exception ex)
|
Width = width.Value
|
||||||
{
|
};
|
||||||
_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dto.OriginalPrimaryImageAspectRatio = size.Width / size.Height;
|
dto.OriginalPrimaryImageAspectRatio = size.Width / size.Height;
|
||||||
|
|
|
@ -1224,6 +1224,6 @@
|
||||||
"MessageNoDevicesSupportCameraUpload": "You currently don't have any devices that support camera upload.",
|
"MessageNoDevicesSupportCameraUpload": "You currently don't have any devices that support camera upload.",
|
||||||
"LabelCameraUploadPath": "Camera upload path:",
|
"LabelCameraUploadPath": "Camera upload path:",
|
||||||
"LabelCameraUploadPathHelp": "Select a custom upload path, if desired. If unspecified a default folder will be used.",
|
"LabelCameraUploadPathHelp": "Select a custom upload path, if desired. If unspecified a default folder will be used.",
|
||||||
"LabelCreateCameraUploadSubfolder": "Create a sub-folder for each device",
|
"LabelCreateCameraUploadSubfolder": "Create a subfolder for each device",
|
||||||
"LabelCreateCameraUploadSubfolderHelp": "Specific folders can be assigned to devices by clicking on the device on the Devices page."
|
"LabelCreateCameraUploadSubfolderHelp": "Specific folders can be assigned to a device by clicking on it from the Devices page."
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1594,7 +1593,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||||
{
|
{
|
||||||
info.ChapterImagesItemId = chapterOwner.Id.ToString("N");
|
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))
|
if (!string.IsNullOrWhiteSpace(mediaSourceId))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user