aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-07-11 12:57:24 -0400
committerGitHub <noreply@github.com>2016-07-11 12:57:24 -0400
commited9727e320792fbdd21dc1c571c1ea4ff0926be2 (patch)
tree85ea66c37568ada0bf08087696b38b178bcf7eee
parent3269223bc451ed76c72b0a90eb6ef002a55c338d (diff)
parent58d904a51a96bc15288b2ff0f99c87cdcb44728a (diff)
Merge pull request #1935 from MediaBrowser/dev
Dev
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs48
-rw-r--r--MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs1
2 files changed, 39 insertions, 10 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
index 8beb03b71..9dd30edde 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
@@ -5,15 +5,19 @@ using MediaBrowser.Model.Entities;
using System;
using System.IO;
using System.Linq;
+using CommonIO;
namespace MediaBrowser.Server.Implementations.Library.Resolvers
{
public class PhotoResolver : ItemResolver<Photo>
{
private readonly IImageProcessor _imageProcessor;
- public PhotoResolver(IImageProcessor imageProcessor)
+ private readonly ILibraryManager _libraryManager;
+
+ public PhotoResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager)
{
_imageProcessor = imageProcessor;
+ _libraryManager = libraryManager;
}
/// <summary>
@@ -23,20 +27,45 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
/// <returns>Trailer.</returns>
protected override Photo Resolve(ItemResolveArgs args)
{
- // Must be an image file within a photo collection
- if (string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase) &&
- !args.IsDirectory &&
- IsImageFile(args.Path, _imageProcessor))
+ if (!args.IsDirectory)
{
- return new Photo
+ // Must be an image file within a photo collection
+ var collectionType = args.GetCollectionType();
+
+ if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{
- Path = args.Path
- };
+ if (IsImageFile(args.Path, _imageProcessor))
+ {
+ var filename = Path.GetFileNameWithoutExtension(args.Path);
+
+ // Make sure the image doesn't belong to a video file
+ if (args.DirectoryService.GetFiles(Path.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(i, filename)))
+ {
+ return null;
+ }
+
+ return new Photo
+ {
+ Path = args.Path
+ };
+ }
+ }
}
return null;
}
+ private bool IsOwnedByMedia(FileSystemMetadata file, string imageFilename)
+ {
+ if (_libraryManager.IsVideoFile(file.FullName) && imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file.Name), StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
private static readonly string[] IgnoreFiles =
{
"folder",
@@ -44,7 +73,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
"landscape",
"fanart",
"backdrop",
- "poster"
+ "poster",
+ "cover"
};
internal static bool IsImageFile(string path, IImageProcessor imageProcessor)
diff --git a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs
index 84d85d667..c2a4339f0 100644
--- a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs
+++ b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs
@@ -154,7 +154,6 @@ namespace MediaBrowser.Server.Implementations.TV
SortOrder = SortOrder.Descending,
IsPlayed = true,
Limit = 1,
- IsVirtualItem = false,
ParentIndexNumberNotEquals = 0
}).FirstOrDefault();