diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations')
4 files changed, 51 insertions, 19 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 9de6972f8..2e2f5e9f8 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -1,10 +1,10 @@ -using System.Threading; -using ServiceStack.Web; +using ServiceStack.Web; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Net; +using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.HttpServer diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs new file mode 100644 index 000000000..2fcfd7086 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoAlbumResolver.cs @@ -0,0 +1,39 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Entities; +using System; +using System.IO; +using System.Linq; + +namespace MediaBrowser.Server.Implementations.Library.Resolvers +{ + public class PhotoAlbumResolver : FolderResolver<PhotoAlbum> + { + /// <summary> + /// Resolves the specified args. + /// </summary> + /// <param name="args">The args.</param> + /// <returns>Trailer.</returns> + protected override PhotoAlbum Resolve(ItemResolveArgs args) + { + // Must be an image file within a photo collection + if (!args.IsRoot && args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) + { + if (HasPhotos(args)) + { + return new PhotoAlbum + { + Path = args.Path + }; + } + } + + return null; + } + + private static bool HasPhotos(ItemResolveArgs args) + { + return args.FileSystemChildren.Any(i => ((i.Attributes & FileAttributes.Directory) != FileAttributes.Directory) && PhotoResolver.IsImageFile(i.FullName)); + } + } +} diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs index cba7aba9a..60e7edfdd 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs @@ -1,24 +1,14 @@ -using MediaBrowser.Controller; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Entities; using System; +using System.IO; using System.Linq; namespace MediaBrowser.Server.Implementations.Library.Resolvers { public class PhotoResolver : ItemResolver<Photo> { - private readonly IServerApplicationPaths _applicationPaths; - - /// <summary> - /// Initializes a new instance of the <see cref="PhotoResolver" /> class. - /// </summary> - /// <param name="applicationPaths">The application paths.</param> - public PhotoResolver(IServerApplicationPaths applicationPaths) - { - _applicationPaths = applicationPaths; - } - /// <summary> /// Resolves the specified args. /// </summary> @@ -27,7 +17,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers protected override Photo Resolve(ItemResolveArgs args) { // Must be an image file within a photo collection - if (!args.IsDirectory && IsImageFile(args.Path) && string.Equals(args.GetCollectionType(), "photos", StringComparison.OrdinalIgnoreCase)) + if (!args.IsDirectory && IsImageFile(args.Path) && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) { return new Photo { @@ -39,10 +29,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers } protected static string[] ImageExtensions = { ".tiff", ".jpeg", ".jpg", ".png", ".aiff" }; - protected bool IsImageFile(string path) + internal static bool IsImageFile(string path) { - return !path.EndsWith("folder.jpg", StringComparison.OrdinalIgnoreCase) - && ImageExtensions.Any(p => path.EndsWith(p, StringComparison.OrdinalIgnoreCase)); + var filename = Path.GetFileName(path); + + return !string.Equals(filename, "folder.jpg", StringComparison.OrdinalIgnoreCase) + && ImageExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase); } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index e8dd54f16..4668d7891 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -174,6 +174,7 @@ <Compile Include="Library\CoreResolutionIgnoreRule.cs" /> <Compile Include="Library\LibraryManager.cs" /> <Compile Include="Library\MusicManager.cs" /> + <Compile Include="Library\Resolvers\PhotoAlbumResolver.cs" /> <Compile Include="Library\Resolvers\PhotoResolver.cs" /> <Compile Include="Library\Resolvers\PlaylistResolver.cs" /> <Compile Include="Library\SearchEngine.cs" /> |
