added error handling to image tag generation
This commit is contained in:
parent
4341bd865d
commit
da5eaddd91
|
@ -292,7 +292,12 @@ namespace MediaBrowser.Controller.Dto
|
|||
{
|
||||
var type = image.Key;
|
||||
|
||||
dto.ImageTags[type] = Kernel.Instance.ImageManager.GetImageCacheTag(item, type, image.Value);
|
||||
var tag = GetImageCacheTag(item, type, image.Value);
|
||||
|
||||
if (tag.HasValue)
|
||||
{
|
||||
dto.ImageTags[type] = tag.Value;
|
||||
}
|
||||
}
|
||||
|
||||
dto.Id = GetClientItemId(item);
|
||||
|
@ -365,7 +370,7 @@ namespace MediaBrowser.Controller.Dto
|
|||
{
|
||||
dto.ParentLogoItemId = GetClientItemId(parentWithLogo);
|
||||
|
||||
dto.ParentLogoImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(parentWithLogo, ImageType.Logo, parentWithLogo.GetImage(ImageType.Logo));
|
||||
dto.ParentLogoImageTag = GetImageCacheTag(parentWithLogo, ImageType.Logo, parentWithLogo.GetImage(ImageType.Logo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,7 +661,7 @@ namespace MediaBrowser.Controller.Dto
|
|||
|
||||
if (!string.IsNullOrEmpty(primaryImagePath))
|
||||
{
|
||||
baseItemPerson.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(entity, ImageType.Primary, primaryImagePath);
|
||||
baseItemPerson.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary, primaryImagePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -712,7 +717,7 @@ namespace MediaBrowser.Controller.Dto
|
|||
|
||||
if (!string.IsNullOrEmpty(primaryImagePath))
|
||||
{
|
||||
studioDto.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(entity, ImageType.Primary, primaryImagePath);
|
||||
studioDto.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary, primaryImagePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -805,7 +810,7 @@ namespace MediaBrowser.Controller.Dto
|
|||
|
||||
if (!string.IsNullOrEmpty(chapterInfo.ImagePath))
|
||||
{
|
||||
dto.ImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Chapter, chapterInfo.ImagePath);
|
||||
dto.ImageTag = GetImageCacheTag(item, ImageType.Chapter, chapterInfo.ImagePath);
|
||||
}
|
||||
|
||||
return dto;
|
||||
|
@ -837,9 +842,15 @@ namespace MediaBrowser.Controller.Dto
|
|||
var imagePath = item.PrimaryImagePath;
|
||||
|
||||
if (!string.IsNullOrEmpty(imagePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
info.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Primary, imagePath);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
@ -980,12 +991,11 @@ namespace MediaBrowser.Controller.Dto
|
|||
/// <returns>List{System.String}.</returns>
|
||||
private List<Guid> GetBackdropImageTags(BaseItem item)
|
||||
{
|
||||
if (item.BackdropImagePaths == null)
|
||||
{
|
||||
return new List<Guid>();
|
||||
}
|
||||
|
||||
return item.BackdropImagePaths.Select(p => Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Backdrop, p)).ToList();
|
||||
return item.BackdropImagePaths
|
||||
.Select(p => GetImageCacheTag(item, ImageType.Backdrop, p))
|
||||
.Where(i => i.HasValue)
|
||||
.Select(i => i.Value)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -995,12 +1005,24 @@ namespace MediaBrowser.Controller.Dto
|
|||
/// <returns>List{Guid}.</returns>
|
||||
private List<Guid> GetScreenshotImageTags(BaseItem item)
|
||||
{
|
||||
if (item.ScreenshotImagePaths == null)
|
||||
{
|
||||
return new List<Guid>();
|
||||
return item.ScreenshotImagePaths
|
||||
.Select(p => GetImageCacheTag(item, ImageType.Screenshot, p))
|
||||
.Where(i => i.HasValue)
|
||||
.Select(i => i.Value)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return item.ScreenshotImagePaths.Select(p => Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Screenshot, p)).ToList();
|
||||
private Guid? GetImageCacheTag(BaseItem item, ImageType type, string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Kernel.Instance.ImageManager.GetImageCacheTag(item, ImageType.Screenshot, path);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting {0} image info for {1}", ex, type, path);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,7 +588,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// Gets or sets the community rating vote count.
|
||||
/// </summary>
|
||||
/// <value>The community rating vote count.</value>
|
||||
public int VoteCount { get; set; }
|
||||
public int? VoteCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the run time ticks.
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public List<LinkedChild> LinkedChildren { get; set; }
|
||||
|
||||
protected virtual bool SupportsLinkedChildren
|
||||
protected virtual bool SupportsShortcutChildren
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
@ -856,6 +856,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
{
|
||||
var parent = System.IO.Path.GetDirectoryName(path);
|
||||
|
||||
// Depending on whether the path is local or unc, it may return either null or '\' at the top
|
||||
while (!string.IsNullOrEmpty(parent) && !parent.ToCharArray()[0].Equals(System.IO.Path.DirectorySeparatorChar))
|
||||
{
|
||||
if (Directory.Exists(parent))
|
||||
|
@ -999,15 +1000,32 @@ namespace MediaBrowser.Controller.Entities
|
|||
public IEnumerable<BaseItem> GetLinkedChildren()
|
||||
{
|
||||
return LinkedChildren
|
||||
.Select(i => LibraryManager.RootFolder.FindByPath(i.Path))
|
||||
.Select(GetLinkedChild)
|
||||
.Where(i => i != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the linked child.
|
||||
/// </summary>
|
||||
/// <param name="info">The info.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
private BaseItem GetLinkedChild(LinkedChild info)
|
||||
{
|
||||
var item = LibraryManager.RootFolder.FindByPath(info.Path);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
Logger.Warn("Unable to find linked item at {0}", info.Path);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public override async Task<bool> RefreshMetadata(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true, bool resetResolveArgs = true)
|
||||
{
|
||||
var changed = await base.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders, resetResolveArgs).ConfigureAwait(false);
|
||||
|
||||
return changed || (SupportsLinkedChildren && LocationType == LocationType.FileSystem && RefreshLinkedChildren());
|
||||
return changed || (SupportsShortcutChildren && LocationType == LocationType.FileSystem && RefreshLinkedChildren());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1059,6 +1077,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks))
|
||||
{
|
||||
Logger.Info("Shortcut links have changed for {0}", Path);
|
||||
newShortcutLinks.AddRange(currentManualLinks);
|
||||
LinkedChildren = newShortcutLinks;
|
||||
return true;
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
/// </summary>
|
||||
public class BoxSet : Folder
|
||||
{
|
||||
protected override bool SupportsLinkedChildren
|
||||
protected override bool SupportsShortcutChildren
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -314,7 +314,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
if (boxset != null)
|
||||
{
|
||||
// See if any movies have a collection id already
|
||||
return boxset.Children.OfType<Video>()
|
||||
return boxset.Children.Concat(boxset.GetLinkedChildren()).OfType<Video>()
|
||||
.Select(i => i.GetProviderId(MetadataProviders.TmdbCollection))
|
||||
.FirstOrDefault(i => i != null);
|
||||
}
|
||||
|
@ -744,7 +744,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
var boxset = movie as BoxSet;
|
||||
Logger.Info("MovieDbProvider - Using rating of first child of boxset...");
|
||||
|
||||
var firstChild = boxset.Children.FirstOrDefault();
|
||||
var firstChild = boxset.Children.Concat(boxset.GetLinkedChildren()).FirstOrDefault();
|
||||
|
||||
boxset.OfficialRating = firstChild != null ? firstChild.OfficialRating : null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user