diff options
| author | crobibero <cody@robibe.ro> | 2020-06-30 17:53:20 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-06-30 17:53:20 -0600 |
| commit | 14faebc7fe7a5a75d4d39ef0c70e6ff0106e76f3 (patch) | |
| tree | 0552309271dd0ff99c4db6f97ed0051f4d888591 /Jellyfin.Api/Helpers/RequestHelpers.cs | |
| parent | 7e94bb786432536e95f4e76ea1f8fe02dd292fef (diff) | |
| parent | d300d80479597faa4a8b6e840f6fcb1efdb63c8c (diff) | |
Merge remote-tracking branch 'upstream/api-migration' into api-livetv
Diffstat (limited to 'Jellyfin.Api/Helpers/RequestHelpers.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/RequestHelpers.cs | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index ce29b90c6..dec8fd95e 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -78,35 +78,13 @@ namespace Jellyfin.Api.Helpers } /// <summary> - /// Gets the item fields. + /// Get Guid array from string. /// </summary> - /// <param name="fields">The item field string.</param> - /// <returns>Array of parsed item fields.</returns> - internal static ItemFields[] GetItemFields(string fields) - { - if (string.IsNullOrEmpty(fields)) - { - return Array.Empty<ItemFields>(); - } - - return Split(fields, ',', true) - .Select(v => - { - if (Enum.TryParse(v, true, out ItemFields value)) - { - return (ItemFields?)value; - } - - return null; - }) - .Where(i => i.HasValue) - .Select(i => i!.Value) - .ToArray(); - } - + /// <param name="value">String value.</param> + /// <returns>Guid array.</returns> internal static Guid[] GetGuids(string? value) { - if (string.IsNullOrEmpty(value)) + if (value == null) { return Array.Empty<Guid>(); } @@ -116,16 +94,20 @@ namespace Jellyfin.Api.Helpers .ToArray(); } + /// <summary> + /// Get orderby. + /// </summary> + /// <param name="sortBy">Sort by.</param> + /// <param name="requestedSortOrder">Sort order.</param> + /// <returns>Resulting order by.</returns> internal static ValueTuple<string, SortOrder>[] GetOrderBy(string? sortBy, string? requestedSortOrder) { - var val = sortBy; - - if (string.IsNullOrEmpty(val)) + if (string.IsNullOrEmpty(sortBy)) { return Array.Empty<ValueTuple<string, SortOrder>>(); } - var vals = val.Split(','); + var vals = sortBy.Split(','); if (string.IsNullOrWhiteSpace(requestedSortOrder)) { requestedSortOrder = "Ascending"; @@ -149,5 +131,18 @@ namespace Jellyfin.Api.Helpers return result; } + + /// <summary> + /// Gets the filters. + /// </summary> + /// <param name="filters">The filter string.</param> + /// <returns>IEnumerable{ItemFilter}.</returns> + internal static ItemFilter[] GetFilters(string filters) + { + return string.IsNullOrEmpty(filters) + ? Array.Empty<ItemFilter>() + : Split(filters, ',', true) + .Select(v => Enum.Parse<ItemFilter>(v, true)).ToArray(); + } } } |
