2013-04-28 00:44:38 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
2014-02-23 20:35:58 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
2013-03-03 06:58:04 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class AudioResolver
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AudioResolver : ItemResolver<Controller.Entities.Audio.Audio>
|
|
|
|
|
{
|
2014-11-16 20:44:08 +00:00
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
|
|
|
|
|
|
public AudioResolver(ILibraryManager libraryManager)
|
|
|
|
|
{
|
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-03 06:58:04 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the priority.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The priority.</value>
|
|
|
|
|
public override ResolverPriority Priority
|
|
|
|
|
{
|
|
|
|
|
get { return ResolverPriority.Last; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves the specified args.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
/// <returns>Entities.Audio.Audio.</returns>
|
|
|
|
|
protected override Controller.Entities.Audio.Audio Resolve(ItemResolveArgs args)
|
|
|
|
|
{
|
|
|
|
|
// Return audio if the path is a file and has a matching extension
|
|
|
|
|
|
|
|
|
|
if (!args.IsDirectory)
|
|
|
|
|
{
|
2014-11-16 20:44:08 +00:00
|
|
|
|
if (_libraryManager.IsAudioFile(args.Path))
|
2013-03-03 06:58:04 +00:00
|
|
|
|
{
|
2014-02-23 20:35:58 +00:00
|
|
|
|
var collectionType = args.GetCollectionType();
|
|
|
|
|
|
2014-12-11 06:20:28 +00:00
|
|
|
|
var isMixed = string.IsNullOrWhiteSpace(collectionType);
|
|
|
|
|
|
|
|
|
|
// For conflicting extensions, give priority to videos
|
|
|
|
|
if (isMixed && _libraryManager.IsVideoFile(args.Path))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-15 03:54:52 +00:00
|
|
|
|
var isStandalone = args.Parent == null;
|
|
|
|
|
|
|
|
|
|
if (isStandalone ||
|
2014-12-11 06:20:28 +00:00
|
|
|
|
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
isMixed)
|
2014-02-23 20:35:58 +00:00
|
|
|
|
{
|
|
|
|
|
return new Controller.Entities.Audio.Audio();
|
|
|
|
|
}
|
2013-03-03 06:58:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|