From 3eb4091808735858b01855d298226d239be464af Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 3 Nov 2016 02:37:52 -0400 Subject: move additional classes to new server lib --- .../Library/Resolvers/Audio/AudioResolver.cs | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs (limited to 'Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs') diff --git a/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs new file mode 100644 index 000000000..d8805355a --- /dev/null +++ b/Emby.Server.Implementations/Library/Resolvers/Audio/AudioResolver.cs @@ -0,0 +1,68 @@ +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Resolvers; +using MediaBrowser.Model.Entities; +using System; + +namespace Emby.Server.Implementations.Library.Resolvers.Audio +{ + /// + /// Class AudioResolver + /// + public class AudioResolver : ItemResolver + { + private readonly ILibraryManager _libraryManager; + + public AudioResolver(ILibraryManager libraryManager) + { + _libraryManager = libraryManager; + } + + /// + /// Gets the priority. + /// + /// The priority. + public override ResolverPriority Priority + { + get { return ResolverPriority.Last; } + } + + /// + /// Resolves the specified args. + /// + /// The args. + /// Entities.Audio.Audio. + protected override MediaBrowser.Controller.Entities.Audio.Audio Resolve(ItemResolveArgs args) + { + // Return audio if the path is a file and has a matching extension + + if (!args.IsDirectory) + { + var libraryOptions = args.GetLibraryOptions(); + + if (_libraryManager.IsAudioFile(args.Path, libraryOptions)) + { + var collectionType = args.GetCollectionType(); + + var isMixed = string.IsNullOrWhiteSpace(collectionType); + + // For conflicting extensions, give priority to videos + if (isMixed && _libraryManager.IsVideoFile(args.Path, libraryOptions)) + { + return null; + } + + var isStandalone = args.Parent == null; + + if (isStandalone || + string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) || + isMixed) + { + return new MediaBrowser.Controller.Entities.Audio.Audio(); + } + } + } + + return null; + } + } +} -- cgit v1.2.3