|
|
@ -79,7 +79,7 @@ namespace MediaBrowser.Api
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// To the optimized serialized result using cache.
|
|
|
|
/// To the optimized serialized result using cache.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -118,9 +118,6 @@ namespace MediaBrowser.Api
|
|
|
|
return ResultFactory.GetStaticFileResult(Request, path);
|
|
|
|
return ResultFactory.GetStaticFileResult(Request, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private readonly char[] _dashReplaceChars = { '?', '/', '&' };
|
|
|
|
|
|
|
|
private const char SlugChar = '-';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected DtoOptions GetDtoOptions(object request)
|
|
|
|
protected DtoOptions GetDtoOptions(object request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var options = new DtoOptions();
|
|
|
|
var options = new DtoOptions();
|
|
|
@ -154,152 +151,122 @@ namespace MediaBrowser.Api
|
|
|
|
|
|
|
|
|
|
|
|
protected MusicArtist GetArtist(string name, ILibraryManager libraryManager)
|
|
|
|
protected MusicArtist GetArtist(string name, ILibraryManager libraryManager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager));
|
|
|
|
if (name.IndexOf(BaseItem.SlugChar) != -1)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
var result = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
protected Studio GetStudio(string name, ILibraryManager libraryManager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SlugName = name,
|
|
|
|
return libraryManager.GetStudio(DeSlugStudioName(name, libraryManager));
|
|
|
|
IncludeItemTypes = new[] { typeof(MusicArtist).Name }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Genre GetGenre(string name, ILibraryManager libraryManager)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return libraryManager.GetGenre(DeSlugGenreName(name, libraryManager));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected MusicGenre GetMusicGenre(string name, ILibraryManager libraryManager)
|
|
|
|
}).OfType<MusicArtist>().FirstOrDefault();
|
|
|
|
{
|
|
|
|
|
|
|
|
return libraryManager.GetMusicGenre(DeSlugGenreName(name, libraryManager));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected GameGenre GetGameGenre(string name, ILibraryManager libraryManager)
|
|
|
|
if (result != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return libraryManager.GetGameGenre(DeSlugGameGenreName(name, libraryManager));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected Person GetPerson(string name, ILibraryManager libraryManager)
|
|
|
|
return libraryManager.GetArtist(name);
|
|
|
|
{
|
|
|
|
|
|
|
|
return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
protected Studio GetStudio(string name, ILibraryManager libraryManager)
|
|
|
|
/// Deslugs an artist name by finding the correct entry in the library
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
|
|
/// <param name="libraryManager"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
protected string DeSlugArtistName(string name, ILibraryManager libraryManager)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name.IndexOf(SlugChar) == -1)
|
|
|
|
if (name.IndexOf(BaseItem.SlugChar) != -1)
|
|
|
|
{
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var items = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IncludeItemTypes = new[] { typeof(Audio).Name, typeof(MusicVideo).Name, typeof(MusicAlbum).Name }
|
|
|
|
var result = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return items
|
|
|
|
|
|
|
|
.OfType<IHasArtist>()
|
|
|
|
|
|
|
|
.SelectMany(i => i.AllArtists)
|
|
|
|
|
|
|
|
.DistinctNames()
|
|
|
|
|
|
|
|
.FirstOrDefault(i =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i = _dashReplaceChars.Aggregate(i, (current, c) => current.Replace(c, SlugChar));
|
|
|
|
SlugName = name,
|
|
|
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Studio).Name }
|
|
|
|
|
|
|
|
|
|
|
|
return string.Equals(i, name, StringComparison.OrdinalIgnoreCase);
|
|
|
|
}).OfType<Studio>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}) ?? name;
|
|
|
|
return libraryManager.GetStudio(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
protected Genre GetGenre(string name, ILibraryManager libraryManager)
|
|
|
|
/// Deslugs a genre name by finding the correct entry in the library
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
protected string DeSlugGenreName(string name, ILibraryManager libraryManager)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name.IndexOf(SlugChar) == -1)
|
|
|
|
if (name.IndexOf(BaseItem.SlugChar) != -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
var result = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return libraryManager.RootFolder.GetRecursiveChildren()
|
|
|
|
|
|
|
|
.SelectMany(i => i.Genres)
|
|
|
|
|
|
|
|
.DistinctNames()
|
|
|
|
|
|
|
|
.FirstOrDefault(i =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i = _dashReplaceChars.Aggregate(i, (current, c) => current.Replace(c, SlugChar));
|
|
|
|
SlugName = name,
|
|
|
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Genre).Name }
|
|
|
|
|
|
|
|
|
|
|
|
return string.Equals(i, name, StringComparison.OrdinalIgnoreCase);
|
|
|
|
}).OfType<Genre>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}) ?? name;
|
|
|
|
return libraryManager.GetGenre(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected string DeSlugGameGenreName(string name, ILibraryManager libraryManager)
|
|
|
|
protected MusicGenre GetMusicGenre(string name, ILibraryManager libraryManager)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name.IndexOf(SlugChar) == -1)
|
|
|
|
if (name.IndexOf(BaseItem.SlugChar) != -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
var result = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
SlugName = name,
|
|
|
|
|
|
|
|
IncludeItemTypes = new[] { typeof(MusicGenre).Name }
|
|
|
|
|
|
|
|
|
|
|
|
var items = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
}).OfType<MusicGenre>().FirstOrDefault();
|
|
|
|
{
|
|
|
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Game).Name }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return items
|
|
|
|
if (result != null)
|
|
|
|
.SelectMany(i => i.Genres)
|
|
|
|
|
|
|
|
.DistinctNames()
|
|
|
|
|
|
|
|
.FirstOrDefault(i =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i = _dashReplaceChars.Aggregate(i, (current, c) => current.Replace(c, SlugChar));
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
return string.Equals(i, name, StringComparison.OrdinalIgnoreCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}) ?? name;
|
|
|
|
return libraryManager.GetMusicGenre(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
protected GameGenre GetGameGenre(string name, ILibraryManager libraryManager)
|
|
|
|
/// Deslugs a studio name by finding the correct entry in the library
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
protected string DeSlugStudioName(string name, ILibraryManager libraryManager)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name.IndexOf(SlugChar) == -1)
|
|
|
|
if (name.IndexOf(BaseItem.SlugChar) != -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
var result = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return libraryManager.RootFolder
|
|
|
|
|
|
|
|
.GetRecursiveChildren()
|
|
|
|
|
|
|
|
.SelectMany(i => i.Studios)
|
|
|
|
|
|
|
|
.DistinctNames()
|
|
|
|
|
|
|
|
.FirstOrDefault(i =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i = _dashReplaceChars.Aggregate(i, (current, c) => current.Replace(c, SlugChar));
|
|
|
|
SlugName = name,
|
|
|
|
|
|
|
|
IncludeItemTypes = new[] { typeof(GameGenre).Name }
|
|
|
|
|
|
|
|
|
|
|
|
return string.Equals(i, name, StringComparison.OrdinalIgnoreCase);
|
|
|
|
}).OfType<GameGenre>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
}) ?? name;
|
|
|
|
if (result != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return libraryManager.GetGameGenre(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
protected Person GetPerson(string name, ILibraryManager libraryManager)
|
|
|
|
/// Deslugs a person name by finding the correct entry in the library
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
protected string DeSlugPersonName(string name, ILibraryManager libraryManager)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name.IndexOf(SlugChar) == -1)
|
|
|
|
if (name.IndexOf(BaseItem.SlugChar) != -1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
var result = libraryManager.GetItemList(new InternalItemsQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return libraryManager.GetPeopleNames(new InternalPeopleQuery())
|
|
|
|
|
|
|
|
.FirstOrDefault(i =>
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i = _dashReplaceChars.Aggregate(i, (current, c) => current.Replace(c, SlugChar));
|
|
|
|
SlugName = name,
|
|
|
|
|
|
|
|
IncludeItemTypes = new[] { typeof(Person).Name }
|
|
|
|
|
|
|
|
|
|
|
|
return string.Equals(i, name, StringComparison.OrdinalIgnoreCase);
|
|
|
|
}).OfType<Person>().FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}) ?? name;
|
|
|
|
return libraryManager.GetPerson(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected string GetPathValue(int index)
|
|
|
|
protected string GetPathValue(int index)
|
|
|
|