|
1 | 1 | namespace Plex.Api.Clients |
2 | 2 | { |
3 | 3 | using System.Collections.Generic; |
| 4 | + using System.Net; |
4 | 5 | using System.Net.Http; |
5 | 6 | using System.Threading.Tasks; |
6 | 7 | using Api; |
@@ -93,32 +94,47 @@ public async Task<MediaContainer> LibrarySearch(string authToken, string plexSer |
93 | 94 | { |
94 | 95 | {"title", title}, |
95 | 96 | {"sort", sort}, |
96 | | - {"libtype", libraryType}, |
97 | | - {"container_start", start.ToString()}, |
98 | | - {"max_results", count.ToString()} |
| 97 | + {"libtype", libraryType} |
99 | 98 | }; |
100 | 99 |
|
101 | 100 | foreach (var item in filters) |
102 | 101 | { |
103 | 102 | queryParams.Add(item.Key, item.Value); |
104 | 103 | } |
105 | 104 |
|
106 | | - return await this.FetchWithWrapper<MediaContainer>(plexServerHost, $"library/sections/{libraryKey}/all", |
107 | | - authToken, HttpMethod.Get, queryParams); |
| 105 | + var apiRequest = |
| 106 | + new ApiRequestBuilder(plexServerHost, $"library/sections/{libraryKey}/all", HttpMethod.Get) |
| 107 | + .AddPlexToken(authToken) |
| 108 | + .AddQueryParams(queryParams) |
| 109 | + .AddQueryParams(ClientUtilities.GetClientIdentifierHeader(this.clientOptions.ClientId)) |
| 110 | + .AddQueryParams(ClientUtilities.GetClientLimitHeaders(start, count)) |
| 111 | + .AcceptJson() |
| 112 | + .Build(); |
| 113 | + |
| 114 | + var wrapper = await this.apiService.InvokeApiAsync<GenericWrapper<MediaContainer>>(apiRequest); |
| 115 | + return wrapper.Container; |
108 | 116 | } |
109 | 117 |
|
110 | 118 | /// <inheritdoc/> |
111 | 119 | public async Task<MediaContainer> GetAll(string authToken, string plexServerHost, string key, string sort, int start, int count) |
112 | 120 | { |
113 | 121 | var queryParams = new Dictionary<string, string> |
114 | 122 | { |
115 | | - {"sort", sort}, |
116 | | - {"container_start", start.ToString()}, |
117 | | - {"max_results", count.ToString()} |
| 123 | + {"sort", sort} |
118 | 124 | }; |
119 | 125 |
|
120 | | - return await this.FetchWithWrapper<MediaContainer>(plexServerHost, $"library/sections/{key}/all", |
121 | | - authToken, HttpMethod.Get, queryParams); |
| 126 | + var apiRequest = |
| 127 | + new ApiRequestBuilder(plexServerHost, $"library/sections/{key}/all", HttpMethod.Get) |
| 128 | + .AddPlexToken(authToken) |
| 129 | + .AddQueryParams(queryParams) |
| 130 | + .AddQueryParams(ClientUtilities.GetClientIdentifierHeader(this.clientOptions.ClientId)) |
| 131 | + .AddQueryParams(ClientUtilities.GetClientLimitHeaders(start, count)) |
| 132 | + .AcceptJson() |
| 133 | + .Build(); |
| 134 | + |
| 135 | + var wrapper = await this.apiService.InvokeApiAsync<GenericWrapper<MediaContainer>>(apiRequest); |
| 136 | + |
| 137 | + return wrapper.Container; |
122 | 138 | } |
123 | 139 |
|
124 | 140 | private async Task<T> FetchWithWrapper<T>(string baseUrl, string endpoint, string authToken, HttpMethod method, |
|
0 commit comments