mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
support null image encoder
This commit is contained in:
@@ -10,6 +10,7 @@ using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Server.Implementations.Photos;
|
||||
using MoreLinq;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
@@ -74,7 +75,27 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||
.DistinctBy(i => i.Id)
|
||||
.ToList();
|
||||
|
||||
return Task.FromResult(GetFinalItems(items));
|
||||
return Task.FromResult(GetFinalItems(items, 2));
|
||||
}
|
||||
|
||||
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var image = itemsWithImages
|
||||
.Where(i => i.HasImage(ImageType.Primary) && i.GetImageInfo(ImageType.Primary, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(ImageType.Primary)))
|
||||
.Select(i => i.GetImagePath(ImageType.Primary))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(image))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(image);
|
||||
|
||||
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
|
||||
File.Copy(image, outputPath);
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +265,11 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||
return true;
|
||||
}
|
||||
|
||||
if (policy.IsAdministrator)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return ListHelper.ContainsIgnoreCase(policy.EnabledDevices, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace MediaBrowser.Server.Implementations.IO
|
||||
// This is an arbitraty amount of time, but delay it because file system writes often trigger events long after the file was actually written to.
|
||||
// Seeing long delays in some situations, especially over the network, sometimes up to 45 seconds
|
||||
// But if we make this delay too high, we risk missing legitimate changes, such as user adding a new file, or hand-editing metadata
|
||||
await Task.Delay(20000).ConfigureAwait(false);
|
||||
await Task.Delay(25000).ConfigureAwait(false);
|
||||
|
||||
string val;
|
||||
_tempIgnoredPaths.TryRemove(path, out val);
|
||||
|
||||
@@ -675,7 +675,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
Name = info.Name,
|
||||
EpisodeTitle = info.EpisodeTitle,
|
||||
ProgramId = info.Id,
|
||||
HasImage = info.HasImage,
|
||||
ImagePath = info.ImagePath,
|
||||
ImageUrl = info.ImageUrl,
|
||||
OriginalAirDate = info.OriginalAirDate,
|
||||
|
||||
@@ -333,7 +333,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
||||
IsRepeat = repeat,
|
||||
IsSeries = showType.IndexOf("series", StringComparison.OrdinalIgnoreCase) != -1,
|
||||
ImageUrl = imageUrl,
|
||||
HasImage = details.hasImageArtwork,
|
||||
IsKids = string.Equals(details.audience, "children", StringComparison.OrdinalIgnoreCase),
|
||||
IsSports = showType.IndexOf("sports", StringComparison.OrdinalIgnoreCase) != -1,
|
||||
IsMovie = showType.IndexOf("movie", StringComparison.OrdinalIgnoreCase) != -1 || showType.IndexOf("film", StringComparison.OrdinalIgnoreCase) != -1,
|
||||
|
||||
@@ -46,11 +46,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DisposeInternal()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected abstract void CloseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,11 +92,11 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
string cacheKey,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var outputPath = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid() + ".png");
|
||||
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
|
||||
var imageCreated = await CreateImage(item, itemsWithImages, outputPath, imageType, 0).ConfigureAwait(false);
|
||||
var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
|
||||
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPathWithoutExtension));
|
||||
string outputPath = await CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0).ConfigureAwait(false);
|
||||
|
||||
if (!imageCreated)
|
||||
if (string.IsNullOrWhiteSpace(outputPath))
|
||||
{
|
||||
return ItemUpdateType.None;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
return parts.GetMD5().ToString("N");
|
||||
}
|
||||
|
||||
protected Task<bool> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
|
||||
protected Task<string> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
|
||||
{
|
||||
return CreateCollage(primaryItem, items, outputPath, 640, 360);
|
||||
}
|
||||
@@ -144,22 +144,22 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i));
|
||||
}
|
||||
|
||||
protected Task<bool> CreatePosterCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
|
||||
protected Task<string> CreatePosterCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
|
||||
{
|
||||
return CreateCollage(primaryItem, items, outputPath, 400, 600);
|
||||
}
|
||||
|
||||
protected Task<bool> CreateSquareCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
|
||||
protected Task<string> CreateSquareCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
|
||||
{
|
||||
return CreateCollage(primaryItem, items, outputPath, 600, 600);
|
||||
}
|
||||
|
||||
protected Task<bool> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
|
||||
protected Task<string> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
|
||||
{
|
||||
return CreateCollage(primaryItem, items, outputPath, width, height);
|
||||
}
|
||||
|
||||
private Task<bool> CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
|
||||
private async Task<string> CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
|
||||
{
|
||||
FileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
|
||||
|
||||
@@ -173,11 +173,16 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
|
||||
if (options.InputPaths.Length == 0)
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
ImageProcessor.CreateImageCollage(options);
|
||||
return Task.FromResult(true);
|
||||
if (!ImageProcessor.SupportsImageCollageCreation)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
await ImageProcessor.CreateImageCollage(options).ConfigureAwait(false);
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
public string Name
|
||||
@@ -185,17 +190,19 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
get { return "Dynamic Image Provider"; }
|
||||
}
|
||||
|
||||
protected virtual async Task<bool> CreateImage(IHasImages item,
|
||||
protected virtual async Task<string> CreateImage(IHasImages item,
|
||||
List<BaseItem> itemsWithImages,
|
||||
string outputPath,
|
||||
string outputPathWithoutExtension,
|
||||
ImageType imageType,
|
||||
int imageIndex)
|
||||
{
|
||||
if (itemsWithImages.Count == 0)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
string outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
||||
|
||||
if (imageType == ImageType.Thumb)
|
||||
{
|
||||
return await CreateThumbCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
|
||||
@@ -207,7 +214,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
{
|
||||
return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
|
||||
}
|
||||
if (item is PhotoAlbum || item is Playlist)
|
||||
if (item is Playlist)
|
||||
{
|
||||
return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
|
||||
}
|
||||
@@ -320,7 +327,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
var random = DateTime.Now.DayOfYear % MaxImageAgeDays;
|
||||
|
||||
return items
|
||||
.OrderBy(i => (random + "" + items.IndexOf(i)).GetMD5())
|
||||
.OrderBy(i => (random + string.Empty + items.IndexOf(i)).GetMD5())
|
||||
.Take(limit)
|
||||
.OrderBy(i => i.Name)
|
||||
.ToList();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
@@ -20,9 +20,26 @@ namespace MediaBrowser.Server.Implementations.Photos
|
||||
protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
|
||||
{
|
||||
var photoAlbum = (PhotoAlbum)item;
|
||||
var items = GetFinalItems(photoAlbum.Children.ToList());
|
||||
var items = GetFinalItems(photoAlbum.Children.ToList(), 1);
|
||||
|
||||
return Task.FromResult(items);
|
||||
}
|
||||
|
||||
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, Model.Entities.ImageType imageType, int imageIndex)
|
||||
{
|
||||
var photoFile = itemsWithImages.Where(i => Path.HasExtension(i.Path)).Select(i => i.Path).FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(photoFile))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(photoFile);
|
||||
|
||||
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
|
||||
File.Copy(photoFile, outputPath);
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using MediaBrowser.Server.Implementations.Photos;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
@@ -97,13 +98,15 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
return item is CollectionFolder;
|
||||
}
|
||||
|
||||
protected override async Task<bool> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPath, ImageType imageType, int imageIndex)
|
||||
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
||||
|
||||
if (imageType == ImageType.Primary)
|
||||
{
|
||||
if (itemsWithImages.Count == 0)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540).ConfigureAwait(false);
|
||||
|
||||
@@ -11,6 +11,7 @@ using MediaBrowser.Server.Implementations.Photos;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
@@ -161,14 +162,16 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
||||
return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty);
|
||||
}
|
||||
|
||||
protected override async Task<bool> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPath, ImageType imageType, int imageIndex)
|
||||
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
||||
{
|
||||
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
||||
|
||||
var view = (UserView)item;
|
||||
if (imageType == ImageType.Primary && IsUsingCollectionStrip(view))
|
||||
{
|
||||
if (itemsWithImages.Count == 0)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return await CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user