update timeline view

pull/702/head
Luke Pulverenti 9 years ago
parent c97a88377f
commit e32dcb38e4

@ -16,6 +16,11 @@ namespace MediaBrowser.Controller.Entities
IEnumerable<string> PhysicalLocations { get; }
}
public interface ISupportsUserSpecificView
{
bool EnableUserSpecificView { get; }
}
public static class CollectionFolderExtensions
{
public static string GetViewType(this ICollectionFolder folder, User user)

@ -144,12 +144,22 @@ namespace MediaBrowser.Controller.Entities
return false;
}
var supportsUserSpecific = folder as ISupportsUserSpecificView;
if (supportsUserSpecific != null && supportsUserSpecific.EnableUserSpecificView)
{
return true;
}
return standaloneTypes.Contains(collectionFolder.CollectionType ?? string.Empty);
}
public static bool IsEligibleForEnhancedView(string viewType)
{
var types = new[] { CollectionType.Movies, CollectionType.TvShows };
var types = new[]
{
CollectionType.Movies,
CollectionType.TvShows
};
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}

@ -78,24 +78,9 @@ namespace MediaBrowser.Server.Implementations.Collections
return Task.FromResult(GetFinalItems(items, 2));
}
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
protected override 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;
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
}
}
}

@ -3,15 +3,15 @@ using MediaBrowser.Controller.Entities;
using System;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Providers;
namespace MediaBrowser.Server.Implementations.Devices
{
public class CameraUploadsFolder : BasePluginFolder
public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView
{
public CameraUploadsFolder()
{
@ -54,6 +54,12 @@ namespace MediaBrowser.Server.Implementations.Devices
_hasChildren = null;
return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
}
[IgnoreDataMember]
public bool EnableUserSpecificView
{
get { return true; }
}
}
public class CameraUploadsDynamicFolder : IVirtualFolderCreator

@ -73,8 +73,6 @@ namespace MediaBrowser.Server.Implementations.Library
var enableUserViews = _config.Configuration.EnableUserViews || user.EnableUserViews;
if (enableUserViews)
{
foreach (var folder in standaloneFolders)
{
var collectionFolder = folder as ICollectionFolder;
@ -83,11 +81,19 @@ namespace MediaBrowser.Server.Implementations.Library
if (UserView.IsUserSpecific(folder))
{
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
continue;
}
else if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
if (enableUserViews)
{
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
{
list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false));
}
else if (_config.Configuration.EnableSharedCollectionViewImage)
{
list.Add(folder);
}
else if (!string.IsNullOrWhiteSpace(folderViewType))
{
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
@ -97,20 +103,10 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(folder);
}
}
}
else
{
// TODO: Deprecate this whole block
foreach (var folder in standaloneFolders)
{
var collectionFolder = folder as ICollectionFolder;
var folderViewType = collectionFolder == null ? null : collectionFolder.CollectionType;
if (UserView.IsUserSpecific(folder))
{
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
else if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
{
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
@ -203,10 +199,15 @@ namespace MediaBrowser.Server.Implementations.Library
return GetUserSubView(name, parentId, type, sortName, cancellationToken);
}
private async Task<UserView> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken)
private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken)
{
if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase)))
{
if (enableUserViews || _config.Configuration.EnableSharedCollectionViewImage)
{
return (Folder)parents[0];
}
var parentId = parents[0].Id;
var enableRichView = !user.Configuration.PlainFolderViews.Contains(parentId.ToString("N"), StringComparer.OrdinalIgnoreCase);

@ -70,6 +70,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />

@ -285,5 +285,25 @@ namespace MediaBrowser.Server.Implementations.Photos
return 0;
}
}
protected async Task<string> CreateSingleImage(List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType)
{
var image = itemsWithImages
.Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType)))
.Select(i => i.GetImagePath(imageType))
.FirstOrDefault();
if (string.IsNullOrWhiteSpace(image))
{
return null;
}
var ext = Path.GetExtension(image);
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ext);
File.Copy(image, outputPath);
return outputPath;
}
}
}

@ -26,24 +26,9 @@ namespace MediaBrowser.Server.Implementations.Photos
return Task.FromResult(items);
}
protected override async Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
protected override 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;
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
}
}
}

Loading…
Cancel
Save