@@ -6,9 +6,6 @@ namespace Plex.Api.Clients
66 using System . Net . Http ;
77 using System . Threading . Tasks ;
88 using Api ;
9- using ApiModels . Libraries ;
10- using ApiModels . Libraries . Filters ;
11- using Automapper ;
129 using Enums ;
1310 using Interfaces ;
1411 using PlexModels ;
@@ -111,10 +108,7 @@ public async Task<MediaContainer> LibrarySearch(string authToken, string plexSer
111108 string libraryKey , string sort , SearchType libraryType , List < FilterRequest > filters = null , int start = 0 ,
112109 int count = 100 )
113110 {
114- var queryParams = new Dictionary < string , string >
115- {
116- { "type" , ( ( int ) libraryType ) . ToString ( ) }
117- } ;
111+ var queryParams = new Dictionary < string , string > { { "type" , ( ( int ) libraryType ) . ToString ( ) } } ;
118112
119113 if ( ! string . IsNullOrEmpty ( title ) )
120114 {
@@ -179,12 +173,10 @@ await this.FetchWithWrapper<FolderContainer>(plexServerHost, $"library/sections/
179173
180174 /// <inheritdoc/>
181175 public async Task < FilterValueContainer > GetLibraryFilterValues ( string authToken , string plexServerHost ,
182- string key , string filterUri )
183- {
184- return await this . FetchWithWrapper < FilterValueContainer > ( plexServerHost ,
176+ string key , string filterUri ) =>
177+ await this . FetchWithWrapper < FilterValueContainer > ( plexServerHost ,
185178 filterUri , authToken ,
186179 HttpMethod . Get ) ;
187- }
188180
189181 /// <inheritdoc/>
190182 public async Task < FilterContainer >
@@ -193,15 +185,20 @@ await this.FetchWithWrapper<FilterContainer>(plexServerHost, $"library/sections/
193185 authToken ,
194186 HttpMethod . Get ) ;
195187
196- /// <inheritdoc/>
197- public async Task < CollectionContainer > GetCollectionsAsync ( string authToken , string plexServerHost , string libraryKey , string title )
188+ /// <inheritdoc/>
189+ public async Task < CollectionContainer > GetCollectionsAsync ( string authToken , string plexServerHost ,
190+ string libraryKey , string title )
198191 {
199192 var queryParams =
200- new Dictionary < string , string > { { "includeCollections" , "1" } , { "includeExternalMedia" , "true" } } ;
193+ new Dictionary < string , string > {
194+ { "includeCollections" , "1" } ,
195+ { "includeExternalMedia" , "true" }
196+
197+ } ;
201198
202199 if ( ! string . IsNullOrEmpty ( title ) )
203200 {
204- queryParams . Add ( "title" , title ) ;
201+ queryParams . Add ( "title" + "%3d" , title ) ;
205202 }
206203
207204 var apiRequest = new ApiRequestBuilder ( plexServerHost , $ "library/sections/{ libraryKey } /collections",
@@ -218,7 +215,8 @@ public async Task<CollectionContainer> GetCollectionsAsync(string authToken, str
218215 }
219216
220217 /// <inheritdoc/>
221- public async Task UpdateCollectionAsync ( string authToken , string plexServerHost , string libraryKey , CollectionModel collectionModel )
218+ public async Task UpdateCollectionAsync ( string authToken , string plexServerHost , string libraryKey ,
219+ CollectionModel collectionModel )
222220 {
223221 if ( authToken == null )
224222 {
@@ -264,26 +262,30 @@ public async Task UpdateCollectionAsync(string authToken, string plexServerHost,
264262 }
265263
266264 /// <inheritdoc/>
267- public async Task < CollectionContainer > GetCollectionAsync ( string authToken , string plexServerHost , string collectionKey )
265+ public async Task < CollectionContainer > GetCollectionAsync ( string authToken , string plexServerHost ,
266+ string collectionKey )
268267 {
269268 var queryParams =
270269 new Dictionary < string , string > { { "includeCollections" , "1" } , { "includeExternalMedia" , "true" } } ;
271270
272- var apiRequest = new ApiRequestBuilder ( plexServerHost , "library/collections/" + collectionKey , HttpMethod . Get )
273- . AddPlexToken ( authToken )
274- . AddQueryParams ( queryParams )
275- . AddRequestHeaders ( ClientUtilities . GetClientIdentifierHeader ( this . clientOptions . ClientId ) )
276- . AcceptJson ( )
277- . Build ( ) ;
271+ var apiRequest =
272+ new ApiRequestBuilder ( plexServerHost , "library/collections/" + collectionKey , HttpMethod . Get )
273+ . AddPlexToken ( authToken )
274+ . AddQueryParams ( queryParams )
275+ . AddRequestHeaders ( ClientUtilities . GetClientIdentifierHeader ( this . clientOptions . ClientId ) )
276+ . AcceptJson ( )
277+ . Build ( ) ;
278278
279279 var wrapper = await this . apiService . InvokeApiAsync < GenericWrapper < CollectionContainer > > ( apiRequest ) ;
280280
281281 return wrapper . Container ;
282282 }
283283
284284 /// <inheritdoc/>
285- public async Task < MediaContainer > GetCollectionItemsAsync ( string authToken , string plexServerHost , string collectionKey ) =>
286- await this . FetchWithWrapper < MediaContainer > ( plexServerHost , "library/metadata/" + collectionKey + "/children" ,
285+ public async Task < MediaContainer > GetCollectionItemsAsync ( string authToken , string plexServerHost ,
286+ string collectionKey ) =>
287+ await this . FetchWithWrapper < MediaContainer > ( plexServerHost ,
288+ "library/metadata/" + collectionKey + "/children" ,
287289 authToken , HttpMethod . Get ) ;
288290
289291 /// <inheritdoc/>
@@ -306,11 +308,26 @@ public async Task<MediaContainer> GetCollectionItemsByCollectionName(string auth
306308 return null ;
307309 }
308310
309- return await this . GetCollectionItemsAsync ( authToken , plexServerHost , collection . Collections . First ( ) . RatingKey ) ;
311+ return await this . GetCollectionItemsAsync ( authToken , plexServerHost ,
312+ collection . Collections . First ( ) . RatingKey ) ;
313+ }
314+
315+ public async Task < MediaContainer > GetCollectionItemMetadataByKey ( string authToken , string plexServerHost , string collectionKey )
316+ {
317+ var apiRequest =
318+ new ApiRequestBuilder ( plexServerHost , $ "library/collections/{ collectionKey } /children", HttpMethod . Get )
319+ . AddPlexToken ( authToken )
320+ . AddRequestHeaders ( ClientUtilities . GetClientIdentifierHeader ( this . clientOptions . ClientId ) )
321+ . AcceptJson ( )
322+ . Build ( ) ;
323+
324+ var wrapper = await this . apiService . InvokeApiAsync < GenericWrapper < MediaContainer > > ( apiRequest ) ;
325+ return wrapper . Container ;
310326 }
311327
312328 /// <inheritdoc/>
313- public async Task AddCollectionToLibraryItemAsync ( string authToken , string plexServerHost , string libraryKey , string ratingKey , string collectionName )
329+ public async Task AddCollectionToLibraryItemAsync ( string authToken , string plexServerHost , string libraryKey ,
330+ string ratingKey , string collectionName )
314331 {
315332 var apiRequest =
316333 new ApiRequestBuilder ( plexServerHost , "library/sections/" + libraryKey + "/all" , HttpMethod . Put )
@@ -331,7 +348,8 @@ public async Task AddCollectionToLibraryItemAsync(string authToken, string plexS
331348 }
332349
333350 /// <inheritdoc/>
334- public async Task DeleteCollectionFromLibraryItemAsync ( string authToken , string plexServerHost , string libraryKey , string ratingKey , string collectionName )
351+ public async Task DeleteCollectionFromLibraryItemAsync ( string authToken , string plexServerHost ,
352+ string libraryKey , string ratingKey , string collectionName )
335353 {
336354 var apiRequest =
337355 new ApiRequestBuilder ( plexServerHost , "library/sections/" + libraryKey + "/all" , HttpMethod . Put )
@@ -351,7 +369,6 @@ public async Task DeleteCollectionFromLibraryItemAsync(string authToken, string
351369 await this . apiService . InvokeApiAsync ( apiRequest ) ;
352370 }
353371
354-
355372 /// <summary>
356373 ///
357374 /// </summary>
0 commit comments