update season queries

This commit is contained in:
Luke Pulverenti
2016-08-18 01:56:10 -04:00
parent d6dc6ffe7e
commit cc62faa1c2
21 changed files with 492 additions and 387 deletions

View File

@@ -829,7 +829,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Person}.</returns>
public Person GetPerson(string name)
{
return GetItemByName<Person>(ConfigurationManager.ApplicationPaths.PeoplePath, name);
return CreateItemByName<Person>(Person.GetPath(name), name);
}
/// <summary>
@@ -839,7 +839,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Studio}.</returns>
public Studio GetStudio(string name)
{
return GetItemByName<Studio>(ConfigurationManager.ApplicationPaths.StudioPath, name);
return CreateItemByName<Studio>(Studio.GetPath(name), name);
}
/// <summary>
@@ -849,7 +849,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
public Genre GetGenre(string name)
{
return GetItemByName<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name);
return CreateItemByName<Genre>(Genre.GetPath(name), name);
}
/// <summary>
@@ -859,7 +859,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{MusicGenre}.</returns>
public MusicGenre GetMusicGenre(string name)
{
return GetItemByName<MusicGenre>(ConfigurationManager.ApplicationPaths.MusicGenrePath, name);
return CreateItemByName<MusicGenre>(MusicGenre.GetPath(name), name);
}
/// <summary>
@@ -869,14 +869,9 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{GameGenre}.</returns>
public GameGenre GetGameGenre(string name)
{
return GetItemByName<GameGenre>(ConfigurationManager.ApplicationPaths.GameGenrePath, name);
return CreateItemByName<GameGenre>(GameGenre.GetPath(name), name);
}
/// <summary>
/// The us culture
/// </summary>
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary>
/// Gets a Year
/// </summary>
@@ -890,19 +885,9 @@ namespace MediaBrowser.Server.Implementations.Library
throw new ArgumentOutOfRangeException("Years less than or equal to 0 are invalid.");
}
return GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture));
}
var name = value.ToString(CultureInfo.InvariantCulture);
/// <summary>
/// Gets the artists path.
/// </summary>
/// <value>The artists path.</value>
public string ArtistsPath
{
get
{
return Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath, "artists");
}
return CreateItemByName<Year>(Year.GetPath(name), name);
}
/// <summary>
@@ -912,48 +897,7 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
public MusicArtist GetArtist(string name)
{
return GetItemByName<MusicArtist>(ArtistsPath, name);
}
private T GetItemByName<T>(string path, string name)
where T : BaseItem, new()
{
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException("path");
}
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name");
}
// Trim the period at the end because windows will have a hard time with that
var validFilename = _fileSystem.GetValidFilename(name)
.Trim()
.TrimEnd('.');
string subFolderPrefix = null;
var type = typeof(T);
if (type == typeof(Person))
{
foreach (char c in validFilename)
{
if (char.IsLetterOrDigit(c))
{
subFolderPrefix = c.ToString();
break;
}
}
}
var fullPath = string.IsNullOrEmpty(subFolderPrefix) ?
Path.Combine(path, validFilename) :
Path.Combine(path, subFolderPrefix, validFilename);
return CreateItemByName<T>(fullPath, name);
return CreateItemByName<MusicArtist>(MusicArtist.GetPath(name), name);
}
private T CreateItemByName<T>(string path, string name)

View File

@@ -166,12 +166,12 @@ namespace MediaBrowser.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes.ToArray(),
IncludeItemTypes = includeItemTypes.ToArray(),
Limit = query.Limit,
IncludeItemsByName = true
IncludeItemsByName = true,
IsVirtualItem = false
});
// Add search hints based on item name
hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item =>
hints.AddRange(mediaItems.Select(item =>
{
var index = GetIndex(item.Name, searchTerm, terms);
@@ -187,20 +187,6 @@ namespace MediaBrowser.Server.Implementations.Library
return Task.FromResult(returnValue);
}
private bool IncludeInSearch(BaseItem item)
{
var episode = item as Episode;
if (episode != null)
{
if (episode.IsMissingEpisode)
{
return false;
}
}
return true;
}
/// <summary>
/// Gets the index.
/// </summary>