aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorVasily <just.one.man@yandex.ru>2020-05-28 17:55:29 +0300
committerVasily <just.one.man@yandex.ru>2020-05-28 17:55:29 +0300
commit9208acd5ae26d41af6791d7dd7322d682a8b80b6 (patch)
tree8bd6b5f1eb79ec02f322f96cf3e58aaa0d87f5cc /MediaBrowser.Controller
parented791dee46b8f3b72fbdb68a3382622b4337e254 (diff)
Convert non-local image to local before computing blurhash
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 07aeb69db..f4b71d8bf 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -2375,6 +2375,46 @@ namespace MediaBrowser.Controller.Entities
.ElementAtOrDefault(imageIndex);
}
+ /// <summary>
+ /// Computes image index for given image or raises if no matching image found.
+ /// </summary>
+ /// <param name="image">Image to compute index for.</param>
+ /// <exception cref="ArgumentException">Image index cannot be computed as no matching image found.
+ /// </exception>
+ /// <returns>Image index.</returns>
+ public int GetImageIndex(ItemImageInfo image)
+ {
+ if (image == null)
+ {
+ throw new ArgumentNullException(nameof(image));
+ }
+
+ if (image.Type == ImageType.Chapter)
+ {
+ var chapters = ItemRepository.GetChapters(this);
+ for (var i = 0; i < chapters.Count; i++)
+ {
+ if (chapters[i].ImagePath == image.Path)
+ {
+ return i;
+ }
+ }
+
+ throw new ArgumentException("No chapter index found for image path", image.Path);
+ }
+
+ var images = GetImages(image.Type).ToArray();
+ for (var i = 0; i < images.Length; i++)
+ {
+ if (images[i].Path == image.Path)
+ {
+ return i;
+ }
+ }
+
+ throw new ArgumentException("No image index found for image path", image.Path);
+ }
+
public IEnumerable<ItemImageInfo> GetImages(ImageType imageType)
{
if (imageType == ImageType.Chapter)