From a77a14eaf689a395caf67fd0f4bbc90fd6a8d251 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 16 May 2013 15:00:42 -0400 Subject: [PATCH] added an alphabet picker to some screens --- MediaBrowser.Api/Library/LibraryHelpers.cs | 2 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs index e956e214d..12b9d478f 100644 --- a/MediaBrowser.Api/Library/LibraryHelpers.cs +++ b/MediaBrowser.Api/Library/LibraryHelpers.cs @@ -75,7 +75,7 @@ namespace MediaBrowser.Api.Library throw new DirectoryNotFoundException("The media collection does not exist"); } - if (Directory.Exists(newPath)) + if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath)) { throw new ArgumentException("There is already a media collection with the name " + newPath + "."); } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index dc316cff1..fcaf599f7 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -127,6 +127,9 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "SeriesStatus", Description = "Optional filter by Series Status. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string SeriesStatus { get; set; } + [ApiMember(Name = "NameStartsWith", Description = "Optional filter whose name begins with a prefix.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string NameStartsWith { get; set; } + /// /// Gets or sets the air days. /// @@ -162,7 +165,7 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "HasTrailer", Description = "Optional filter by items with trailers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public bool? HasTrailer { get; set; } - + /// /// Gets the order by. /// @@ -450,7 +453,12 @@ namespace MediaBrowser.Api.UserLibrary var vals = request.IncludeItemTypes.Split(','); items = items.Where(f => vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase)); } - + + if (!string.IsNullOrEmpty(request.NameStartsWith)) + { + items = items.Where(i => i.Name.IndexOf(request.NameStartsWith, StringComparison.OrdinalIgnoreCase) == 0); + } + // Filter by Series Status if (!string.IsNullOrEmpty(request.SeriesStatus)) { @@ -489,7 +497,7 @@ namespace MediaBrowser.Api.UserLibrary items = items.Where(i => !string.IsNullOrEmpty(i.MediaType) && types.Contains(i.MediaType, StringComparer.OrdinalIgnoreCase)); } - + var imageTypes = GetImageTypes(request).ToArray(); if (imageTypes.Length > 0) {