support image placeholders
This commit is contained in:
parent
fe5537f779
commit
057c4b5494
|
@ -1479,6 +1479,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
image.Path = file.FullName;
|
image.Path = file.FullName;
|
||||||
image.DateModified = imageInfo.DateModified;
|
image.DateModified = imageInfo.DateModified;
|
||||||
|
image.IsPlaceholder = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// <value>The date modified.</value>
|
/// <value>The date modified.</value>
|
||||||
public DateTime DateModified { get; set; }
|
public DateTime DateModified { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this instance is placeholder.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance is placeholder; otherwise, <c>false</c>.</value>
|
||||||
|
public bool IsPlaceholder { get; set; }
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public bool IsLocalFile
|
public bool IsLocalFile
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
if (!IsEnabled(savedOptions, imageType, item)) continue;
|
if (!IsEnabled(savedOptions, imageType, item)) continue;
|
||||||
|
|
||||||
if (!item.HasImage(imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
||||||
{
|
{
|
||||||
_logger.Debug("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name);
|
_logger.Debug("Running {0} for {1}", provider.GetType().Name, item.Path ?? item.Name);
|
||||||
|
|
||||||
|
@ -199,6 +199,14 @@ namespace MediaBrowser.Providers.Manager
|
||||||
ImageType.Thumb
|
ImageType.Thumb
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private bool HasImage(IHasImages item, ImageType type)
|
||||||
|
{
|
||||||
|
var image = item.GetImageInfo(type, 0);
|
||||||
|
|
||||||
|
// if it's a placeholder image then pretend like it's not there so that we can replace it
|
||||||
|
return image != null && !image.IsPlaceholder;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if an item already contains the given images
|
/// Determines if an item already contains the given images
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -210,7 +218,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
/// <returns><c>true</c> if the specified item contains images; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the specified item contains images; otherwise, <c>false</c>.</returns>
|
||||||
private bool ContainsImages(IHasImages item, List<ImageType> images, MetadataOptions savedOptions, int backdropLimit, int screenshotLimit)
|
private bool ContainsImages(IHasImages item, List<ImageType> images, MetadataOptions savedOptions, int backdropLimit, int screenshotLimit)
|
||||||
{
|
{
|
||||||
if (_singularImages.Any(i => images.Contains(i) && !item.HasImage(i) && savedOptions.GetLimit(i) > 0))
|
if (_singularImages.Any(i => images.Contains(i) && !HasImage(item, i) && savedOptions.GetLimit(i) > 0))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +290,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
{
|
{
|
||||||
if (!IsEnabled(savedOptions, imageType, item)) continue;
|
if (!IsEnabled(savedOptions, imageType, item)) continue;
|
||||||
|
|
||||||
if (!item.HasImage(imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
if (!HasImage(item, imageType) || (refreshOptions.IsReplacingImage(imageType) && !downloadedImages.Contains(imageType)))
|
||||||
{
|
{
|
||||||
minWidth = savedOptions.GetMinWidth(imageType);
|
minWidth = savedOptions.GetMinWidth(imageType);
|
||||||
var downloaded = await DownloadImage(item, provider, result, list, minWidth, imageType, cancellationToken).ConfigureAwait(false);
|
var downloaded = await DownloadImage(item, provider, result, list, minWidth, imageType, cancellationToken).ConfigureAwait(false);
|
||||||
|
@ -613,4 +621,4 @@ namespace MediaBrowser.Providers.Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -653,13 +653,26 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||||
item.IndexNumber = info.EpisodeNumber;
|
item.IndexNumber = info.EpisodeNumber;
|
||||||
item.ParentIndexNumber = info.SeasonNumber;
|
item.ParentIndexNumber = info.SeasonNumber;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(info.ImagePath))
|
if (!item.HasImage(ImageType.Primary))
|
||||||
{
|
{
|
||||||
item.SetImagePath(ImageType.Primary, info.ImagePath);
|
if (!string.IsNullOrWhiteSpace(info.ImagePath))
|
||||||
}
|
{
|
||||||
else if (!string.IsNullOrWhiteSpace(info.ImageUrl))
|
item.SetImage(new ItemImageInfo
|
||||||
{
|
{
|
||||||
item.SetImagePath(ImageType.Primary, info.ImageUrl);
|
Path = info.ImagePath,
|
||||||
|
Type = ImageType.Primary,
|
||||||
|
IsPlaceholder = true
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrWhiteSpace(info.ImageUrl))
|
||||||
|
{
|
||||||
|
item.SetImage(new ItemImageInfo
|
||||||
|
{
|
||||||
|
Path = info.ImageUrl,
|
||||||
|
Type = ImageType.Primary,
|
||||||
|
IsPlaceholder = true
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNew)
|
if (isNew)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user