factor collection type in resolving process

pull/702/head
Luke Pulverenti 11 years ago
parent a4142e8764
commit 898d55d866

@ -240,6 +240,22 @@ namespace MediaBrowser.Model.ApiClient
/// <exception cref="ArgumentNullException">userId</exception>
Task<BaseItemDto> GetGenreAsync(string name, string userId);
/// <summary>
/// Gets the music genre async.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="userId">The user id.</param>
/// <returns>Task{BaseItemDto}.</returns>
Task<BaseItemDto> GetMusicGenreAsync(string name, string userId);
/// <summary>
/// Gets the game genre async.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="userId">The user id.</param>
/// <returns>Task{BaseItemDto}.</returns>
Task<BaseItemDto> GetGameGenreAsync(string name, string userId);
/// <summary>
/// Gets the artist async.
/// </summary>

@ -1,6 +1,8 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -12,6 +14,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
/// </summary>
public class MusicAlbumResolver : ItemResolver<MusicAlbum>
{
private readonly ILibraryManager _libraryManager;
public MusicAlbumResolver(ILibraryManager libraryManager)
{
_libraryManager = libraryManager;
}
/// <summary>
/// Gets the priority.
/// </summary>
@ -35,6 +44,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
if (args.Parent.IsRoot) return null;
if (args.Parent is MusicAlbum) return null;
var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);
// If there's a collection type and it's not music, it can't be a series
if (!string.IsNullOrEmpty(collectionType) &&
!string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
{
return null;
}
return IsMusicAlbum(args) ? new MusicAlbum
{
DisplayMediaType = "Album"

@ -1,6 +1,8 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Resolvers;
using MediaBrowser.Model.Entities;
using System;
using System.IO;
using System.Linq;
@ -11,6 +13,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
/// </summary>
public class MusicArtistResolver : ItemResolver<MusicArtist>
{
private readonly ILibraryManager _libraryManager;
public MusicArtistResolver(ILibraryManager libraryManager)
{
_libraryManager = libraryManager;
}
/// <summary>
/// Gets the priority.
/// </summary>
@ -39,6 +48,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
return null;
}
var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);
// If there's a collection type and it's not music, it can't be a series
if (!string.IsNullOrEmpty(collectionType) &&
!string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
{
return null;
}
// If we contain an album assume we are an artist folder
return args.FileSystemChildren.Where(i => (i.Attributes & FileAttributes.Directory) == FileAttributes.Directory).Any(i => MusicAlbumResolver.IsMusicAlbum(i.FullName)) ? new MusicArtist() : null;
}

@ -13,6 +13,13 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
/// </summary>
public class SeriesResolver : FolderResolver<Series>
{
private readonly ILibraryManager _libraryManager;
public SeriesResolver(ILibraryManager libraryManager)
{
_libraryManager = libraryManager;
}
/// <summary>
/// Gets the priority.
/// </summary>
@ -46,6 +53,15 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
return null;
}
var collectionType = args.Parent == null ? null : _libraryManager.FindCollectionType(args.Parent);
// If there's a collection type and it's not tv, it can't be a series
if (!string.IsNullOrEmpty(collectionType) &&
!string.Equals(collectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{
return null;
}
// It's a Series if any of the following conditions are met:
// series.xml exists
// [tvdbid= is present in the path

Loading…
Cancel
Save