diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-08-18 01:57:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-18 01:57:43 -0400 |
| commit | edb956febcad89779b455e2a7f9e26b1d46d1625 (patch) | |
| tree | 1a8b7a47bc688ef8115656d59492a5bbc3e6bd48 /MediaBrowser.Server.Implementations/Library/LibraryManager.cs | |
| parent | 6b47232b15f7398af28843049f11070de20fab3f (diff) | |
| parent | cc62faa1c2c212d07c556e5368888ecc3ee537eb (diff) | |
Merge pull request #2069 from MediaBrowser/dev
update season queries
Diffstat (limited to 'MediaBrowser.Server.Implementations/Library/LibraryManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 72 |
1 files changed, 8 insertions, 64 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index a19f70e68..a5e6c1b92 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -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,15 +869,10 @@ 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> /// <param name="value">The value.</param> @@ -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) |
