@@ -191,7 +191,17 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat
191
191
var localPosterPath = Path . Combine ( fullFolderPath , $ "{ IconUtils . GetImageName ( ) } .png") ;
192
192
var posterUrl = GetPosterUrl ( result . PosterPath , PosterSize . Original , client ) ;
193
193
194
- string type = PickResult ( result , resultType , fullFolderPath , rating , isPickedById , out int id , folderName , localPosterPath ) ;
194
+ var resultDetails = new SearchResultData
195
+ {
196
+ Result = result ,
197
+ ResultType = resultType ,
198
+ FullFolderPath = fullFolderPath ,
199
+ Rating = rating ,
200
+ IsPickedById = isPickedById ,
201
+ FolderName = folderName ,
202
+ LocalPosterPath = localPosterPath ,
203
+ } ;
204
+ var type = PickResult ( resultDetails , out var id ) ;
195
205
196
206
if ( ! isPickedById && id != 0 )
197
207
{
@@ -219,61 +229,53 @@ private static string PrepareRating(string resultType, string rating, dynamic re
219
229
return rating ;
220
230
}
221
231
222
- private string PickResult ( dynamic result ,
223
- string resultType ,
224
- string fullFolderPath ,
225
- string rating ,
226
- bool isPickedById ,
227
- out int id ,
228
- string folderName ,
229
- string localPosterPath )
232
+ private string PickResult ( SearchResultData details , out int id )
230
233
{
231
234
id = 0 ;
232
- var mediaType = resultType ;
233
- switch ( resultType )
235
+ var mediaType = details . ResultType ;
236
+ switch ( mediaType )
234
237
{
235
238
case MediaTypes . Tv :
236
- {
237
- var pickedResult = CastResult ( isPickedById ? typeof ( TvShow ) : typeof ( SearchTv ) , result ) ;
238
- var year = pickedResult . FirstAirDate ? . Year . ToString ( CultureInfo . InvariantCulture ) ?? "" ;
239
- AddToPickedList ( pickedResult . Name , year , rating , fullFolderPath , folderName , localPosterPath ) ;
240
- id = pickedResult . Id ;
241
- break ;
242
- }
239
+ {
240
+ var pickedResult = CastResult ( details . IsPickedById ? typeof ( TvShow ) : typeof ( SearchTv ) , details . Result ) ;
241
+ var year = pickedResult . FirstAirDate ? . Year . ToString ( CultureInfo . InvariantCulture ) ?? "" ;
242
+ AddToPickedList ( pickedResult . Name , year , details . Rating , details . FullFolderPath , details . FolderName , details . LocalPosterPath ) ;
243
+ id = pickedResult . Id ;
244
+ break ;
245
+ }
243
246
case MediaTypes . Movie :
244
- {
245
- var pickedResult = CastResult ( isPickedById ? typeof ( Movie ) : typeof ( SearchMovie ) , result ) ;
246
- var year = pickedResult . ReleaseDate ? . Year . ToString ( CultureInfo . InvariantCulture ) ?? "" ;
247
- AddToPickedList ( pickedResult . Title , year , rating , fullFolderPath , folderName , localPosterPath ) ;
248
- id = pickedResult . Id ;
249
- break ;
250
- }
247
+ {
248
+ var pickedResult = CastResult ( details . IsPickedById ? typeof ( Movie ) : typeof ( SearchMovie ) , details . Result ) ;
249
+ var year = pickedResult . ReleaseDate ? . Year . ToString ( CultureInfo . InvariantCulture ) ?? "" ;
250
+ AddToPickedList ( pickedResult . Title , year , details . Rating , details . FullFolderPath , details . FolderName , details . LocalPosterPath ) ;
251
+ id = pickedResult . Id ;
252
+ break ;
253
+ }
251
254
case MediaTypes . Collection :
252
- {
253
- var pickedResult = CastResult ( isPickedById ? typeof ( Collection ) : typeof ( SearchCollection ) , result ) ;
254
- AddToPickedList ( pickedResult . Name , null , rating , fullFolderPath , folderName , localPosterPath ) ;
255
- id = pickedResult . Id ;
256
- break ;
257
- }
255
+ {
256
+ var pickedResult = CastResult ( details . IsPickedById ? typeof ( Collection ) : typeof ( SearchCollection ) , details . Result ) ;
257
+ AddToPickedList ( pickedResult . Name , null , details . Rating , details . FullFolderPath , details . FolderName , details . LocalPosterPath ) ;
258
+ id = pickedResult . Id ;
259
+ break ;
260
+ }
258
261
case MediaTypes . Mtv :
259
- mediaType = SelectMtvType ( result , fullFolderPath , rating , isPickedById , out id , folderName , localPosterPath ) ;
262
+ mediaType = SelectMtvType ( details , out id ) ;
260
263
break ;
261
- default : throw new InvalidDataException ( $ "Invalid Result Type: { resultType } ") ;
264
+ default : throw new InvalidDataException ( $ "Invalid Result Type: { mediaType } ") ;
262
265
}
263
266
264
267
return mediaType ;
265
268
}
266
269
267
- private string SelectMtvType ( dynamic result , string fullFolderPath , string rating , bool isPickedById , out int id , string folderName , string localPosterPath )
270
+ private string SelectMtvType ( SearchResultData details , out int id )
268
271
{
269
- var mediaType = result . MediaType ;
272
+ var mediaType = details . Result . MediaType ;
270
273
id = 0 ;
274
+ details . ResultType = mediaType . ToString ( ) ;
271
275
return mediaType switch
272
276
{
273
- MediaType . Tv => PickResult ( result , MediaTypes . Tv , fullFolderPath , rating , isPickedById , out id , folderName ,
274
- localPosterPath ) ,
275
- MediaType . Movie => PickResult ( result , MediaTypes . Movie , fullFolderPath , rating , isPickedById , out id ,
276
- folderName , localPosterPath ) ,
277
+ MediaType . Tv => PickResult ( details , out id ) ,
278
+ MediaType . Movie => PickResult ( details , out id ) ,
277
279
_ => mediaType
278
280
} ;
279
281
}
0 commit comments