BaseItemsRequest.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. using System;
  2. using System.Linq;
  3. using MediaBrowser.Model.Entities;
  4. using MediaBrowser.Model.Querying;
  5. using MediaBrowser.Model.Services;
  6. namespace MediaBrowser.Api.UserLibrary
  7. {
  8. public abstract class BaseItemsRequest : IHasDtoOptions
  9. {
  10. protected BaseItemsRequest()
  11. {
  12. EnableImages = true;
  13. EnableTotalRecordCount = true;
  14. }
  15. /// <summary>
  16. /// Gets or sets the max offical rating.
  17. /// </summary>
  18. /// <value>The max offical rating.</value>
  19. [ApiMember(Name = "MaxOfficialRating", Description = "Optional filter by maximum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  20. public string MaxOfficialRating { get; set; }
  21. [ApiMember(Name = "HasThemeSong", Description = "Optional filter by items with theme songs.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  22. public bool? HasThemeSong { get; set; }
  23. [ApiMember(Name = "HasThemeVideo", Description = "Optional filter by items with theme videos.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  24. public bool? HasThemeVideo { get; set; }
  25. [ApiMember(Name = "HasSubtitles", Description = "Optional filter by items with subtitles.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  26. public bool? HasSubtitles { get; set; }
  27. [ApiMember(Name = "HasSpecialFeature", Description = "Optional filter by items with special features.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  28. public bool? HasSpecialFeature { get; set; }
  29. [ApiMember(Name = "HasTrailer", Description = "Optional filter by items with trailers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  30. public bool? HasTrailer { get; set; }
  31. [ApiMember(Name = "AdjacentTo", Description = "Optional. Return items that are siblings of a supplied item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  32. public string AdjacentTo { get; set; }
  33. [ApiMember(Name = "MinIndexNumber", Description = "Optional filter by minimum index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  34. public int? MinIndexNumber { get; set; }
  35. [ApiMember(Name = "ParentIndexNumber", Description = "Optional filter by parent index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  36. public int? ParentIndexNumber { get; set; }
  37. [ApiMember(Name = "HasParentalRating", Description = "Optional filter by items that have or do not have a parental rating", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  38. public bool? HasParentalRating { get; set; }
  39. [ApiMember(Name = "IsHD", Description = "Optional filter by items that are HD or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  40. public bool? IsHD { get; set; }
  41. public bool? Is4K { get; set; }
  42. [ApiMember(Name = "LocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  43. public string LocationTypes { get; set; }
  44. [ApiMember(Name = "ExcludeLocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  45. public string ExcludeLocationTypes { get; set; }
  46. [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  47. public bool? IsMissing { get; set; }
  48. [ApiMember(Name = "IsUnaired", Description = "Optional filter by items that are unaired episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  49. public bool? IsUnaired { get; set; }
  50. [ApiMember(Name = "MinCommunityRating", Description = "Optional filter by minimum community rating.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  51. public double? MinCommunityRating { get; set; }
  52. [ApiMember(Name = "MinCriticRating", Description = "Optional filter by minimum critic rating.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  53. public double? MinCriticRating { get; set; }
  54. [ApiMember(Name = "AiredDuringSeason", Description = "Gets all episodes that aired during a season, including specials.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  55. public int? AiredDuringSeason { get; set; }
  56. [ApiMember(Name = "MinPremiereDate", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  57. public string MinPremiereDate { get; set; }
  58. [ApiMember(Name = "MinDateLastSaved", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  59. public string MinDateLastSaved { get; set; }
  60. [ApiMember(Name = "MinDateLastSavedForUser", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  61. public string MinDateLastSavedForUser { get; set; }
  62. [ApiMember(Name = "MaxPremiereDate", Description = "Optional. The maximum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  63. public string MaxPremiereDate { get; set; }
  64. [ApiMember(Name = "HasOverview", Description = "Optional filter by items that have an overview or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  65. public bool? HasOverview { get; set; }
  66. [ApiMember(Name = "HasImdbId", Description = "Optional filter by items that have an imdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  67. public bool? HasImdbId { get; set; }
  68. [ApiMember(Name = "HasTmdbId", Description = "Optional filter by items that have a tmdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  69. public bool? HasTmdbId { get; set; }
  70. [ApiMember(Name = "HasTvdbId", Description = "Optional filter by items that have a tvdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  71. public bool? HasTvdbId { get; set; }
  72. [ApiMember(Name = "ExcludeItemIds", Description = "Optional. If specified, results will be filtered by exxcluding item ids. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  73. public string ExcludeItemIds { get; set; }
  74. public bool EnableTotalRecordCount { get; set; }
  75. /// <summary>
  76. /// Skips over a given number of items within the results. Use for paging.
  77. /// </summary>
  78. /// <value>The start index.</value>
  79. [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  80. public int? StartIndex { get; set; }
  81. /// <summary>
  82. /// The maximum number of items to return
  83. /// </summary>
  84. /// <value>The limit.</value>
  85. [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  86. public int? Limit { get; set; }
  87. /// <summary>
  88. /// Whether or not to perform the query recursively
  89. /// </summary>
  90. /// <value><c>true</c> if recursive; otherwise, <c>false</c>.</value>
  91. [ApiMember(Name = "Recursive", Description = "When searching within folders, this determines whether or not the search will be recursive. true/false", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
  92. public bool Recursive { get; set; }
  93. public string SearchTerm { get; set; }
  94. /// <summary>
  95. /// Gets or sets the sort order.
  96. /// </summary>
  97. /// <value>The sort order.</value>
  98. [ApiMember(Name = "SortOrder", Description = "Sort Order - Ascending,Descending", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  99. public string SortOrder { get; set; }
  100. /// <summary>
  101. /// Specify this to localize the search to a specific item or folder. Omit to use the root.
  102. /// </summary>
  103. /// <value>The parent id.</value>
  104. [ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  105. public string ParentId { get; set; }
  106. /// <summary>
  107. /// Fields to return within the items, in addition to basic information
  108. /// </summary>
  109. /// <value>The fields.</value>
  110. [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  111. public string Fields { get; set; }
  112. /// <summary>
  113. /// Gets or sets the exclude item types.
  114. /// </summary>
  115. /// <value>The exclude item types.</value>
  116. [ApiMember(Name = "ExcludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  117. public string ExcludeItemTypes { get; set; }
  118. /// <summary>
  119. /// Gets or sets the include item types.
  120. /// </summary>
  121. /// <value>The include item types.</value>
  122. [ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  123. public string IncludeItemTypes { get; set; }
  124. /// <summary>
  125. /// Filters to apply to the results
  126. /// </summary>
  127. /// <value>The filters.</value>
  128. [ApiMember(Name = "Filters", Description = "Optional. Specify additional filters to apply. This allows multiple, comma delimeted. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  129. public string Filters { get; set; }
  130. /// <summary>
  131. /// Gets or sets the Isfavorite option
  132. /// </summary>
  133. /// <value>IsFavorite</value>
  134. [ApiMember(Name = "IsFavorite", Description = "Optional filter by items that are marked as favorite, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  135. public bool? IsFavorite { get; set; }
  136. /// <summary>
  137. /// Gets or sets the media types.
  138. /// </summary>
  139. /// <value>The media types.</value>
  140. [ApiMember(Name = "MediaTypes", Description = "Optional filter by MediaType. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  141. public string MediaTypes { get; set; }
  142. /// <summary>
  143. /// Gets or sets the image types.
  144. /// </summary>
  145. /// <value>The image types.</value>
  146. [ApiMember(Name = "ImageTypes", Description = "Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  147. public string ImageTypes { get; set; }
  148. /// <summary>
  149. /// What to sort the results by
  150. /// </summary>
  151. /// <value>The sort by.</value>
  152. [ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  153. public string SortBy { get; set; }
  154. [ApiMember(Name = "IsPlayed", Description = "Optional filter by items that are played, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  155. public bool? IsPlayed { get; set; }
  156. /// <summary>
  157. /// Limit results to items containing specific genres
  158. /// </summary>
  159. /// <value>The genres.</value>
  160. [ApiMember(Name = "Genres", Description = "Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  161. public string Genres { get; set; }
  162. public string GenreIds { get; set; }
  163. [ApiMember(Name = "OfficialRatings", Description = "Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  164. public string OfficialRatings { get; set; }
  165. [ApiMember(Name = "Tags", Description = "Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  166. public string Tags { get; set; }
  167. /// <summary>
  168. /// Limit results to items containing specific years
  169. /// </summary>
  170. /// <value>The years.</value>
  171. [ApiMember(Name = "Years", Description = "Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  172. public string Years { get; set; }
  173. [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
  174. public bool? EnableImages { get; set; }
  175. [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
  176. public bool? EnableUserData { get; set; }
  177. [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  178. public int? ImageTypeLimit { get; set; }
  179. [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  180. public string EnableImageTypes { get; set; }
  181. /// <summary>
  182. /// Limit results to items containing a specific person
  183. /// </summary>
  184. /// <value>The person.</value>
  185. [ApiMember(Name = "Person", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  186. public string Person { get; set; }
  187. [ApiMember(Name = "PersonIds", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  188. public string PersonIds { get; set; }
  189. /// <summary>
  190. /// If the Person filter is used, this can also be used to restrict to a specific person type
  191. /// </summary>
  192. /// <value>The type of the person.</value>
  193. [ApiMember(Name = "PersonTypes", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  194. public string PersonTypes { get; set; }
  195. /// <summary>
  196. /// Limit results to items containing specific studios
  197. /// </summary>
  198. /// <value>The studios.</value>
  199. [ApiMember(Name = "Studios", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  200. public string Studios { get; set; }
  201. [ApiMember(Name = "StudioIds", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  202. public string StudioIds { get; set; }
  203. /// <summary>
  204. /// Gets or sets the studios.
  205. /// </summary>
  206. /// <value>The studios.</value>
  207. [ApiMember(Name = "Artists", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  208. public string Artists { get; set; }
  209. public string ExcludeArtistIds { get; set; }
  210. [ApiMember(Name = "ArtistIds", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  211. public string ArtistIds { get; set; }
  212. public string AlbumArtistIds { get; set; }
  213. public string ContributingArtistIds { get; set; }
  214. [ApiMember(Name = "Albums", Description = "Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  215. public string Albums { get; set; }
  216. public string AlbumIds { get; set; }
  217. /// <summary>
  218. /// Gets or sets the item ids.
  219. /// </summary>
  220. /// <value>The item ids.</value>
  221. [ApiMember(Name = "Ids", Description = "Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  222. public string Ids { get; set; }
  223. /// <summary>
  224. /// Gets or sets the video types.
  225. /// </summary>
  226. /// <value>The video types.</value>
  227. [ApiMember(Name = "VideoTypes", Description = "Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  228. public string VideoTypes { get; set; }
  229. /// <summary>
  230. /// Gets or sets the user id.
  231. /// </summary>
  232. /// <value>The user id.</value>
  233. [ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  234. public Guid UserId { get; set; }
  235. /// <summary>
  236. /// Gets or sets the min offical rating.
  237. /// </summary>
  238. /// <value>The min offical rating.</value>
  239. [ApiMember(Name = "MinOfficialRating", Description = "Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  240. public string MinOfficialRating { get; set; }
  241. [ApiMember(Name = "IsLocked", Description = "Optional filter by items that are locked.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  242. public bool? IsLocked { get; set; }
  243. [ApiMember(Name = "IsPlaceHolder", Description = "Optional filter by items that are placeholders", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  244. public bool? IsPlaceHolder { get; set; }
  245. [ApiMember(Name = "HasOfficialRating", Description = "Optional filter by items that have official ratings", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  246. public bool? HasOfficialRating { get; set; }
  247. [ApiMember(Name = "CollapseBoxSetItems", Description = "Whether or not to hide items behind their boxsets.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  248. public bool? CollapseBoxSetItems { get; set; }
  249. public int? MinWidth { get; set; }
  250. public int? MinHeight { get; set; }
  251. public int? MaxWidth { get; set; }
  252. public int? MaxHeight { get; set; }
  253. /// <summary>
  254. /// Gets or sets the video formats.
  255. /// </summary>
  256. /// <value>The video formats.</value>
  257. [ApiMember(Name = "Is3D", Description = "Optional filter by items that are 3D, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  258. public bool? Is3D { get; set; }
  259. /// <summary>
  260. /// Gets or sets the series status.
  261. /// </summary>
  262. /// <value>The series status.</value>
  263. [ApiMember(Name = "SeriesStatus", Description = "Optional filter by Series Status. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  264. public string SeriesStatus { get; set; }
  265. [ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  266. public string NameStartsWithOrGreater { get; set; }
  267. [ApiMember(Name = "NameStartsWith", Description = "Optional filter by items whose name is sorted equally than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  268. public string NameStartsWith { get; set; }
  269. [ApiMember(Name = "NameLessThan", Description = "Optional filter by items whose name is equally or lesser than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  270. public string NameLessThan { get; set; }
  271. public string[] GetGenres()
  272. {
  273. return (Genres ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  274. }
  275. public string[] GetTags()
  276. {
  277. return (Tags ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  278. }
  279. public string[] GetOfficialRatings()
  280. {
  281. return (OfficialRatings ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  282. }
  283. public string[] GetMediaTypes()
  284. {
  285. return (MediaTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  286. }
  287. public string[] GetIncludeItemTypes()
  288. {
  289. return (IncludeItemTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  290. }
  291. public string[] GetExcludeItemTypes()
  292. {
  293. return (ExcludeItemTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  294. }
  295. public int[] GetYears()
  296. {
  297. return (Years ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  298. }
  299. public string[] GetStudios()
  300. {
  301. return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  302. }
  303. public string[] GetPersonTypes()
  304. {
  305. return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  306. }
  307. public VideoType[] GetVideoTypes()
  308. {
  309. if (string.IsNullOrEmpty(VideoTypes))
  310. {
  311. return Array.Empty<VideoType>();
  312. }
  313. return VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
  314. }
  315. /// <summary>
  316. /// Gets the filters.
  317. /// </summary>
  318. /// <returns>IEnumerable{ItemFilter}.</returns>
  319. public ItemFilter[] GetFilters()
  320. {
  321. var val = Filters;
  322. if (string.IsNullOrEmpty(val))
  323. {
  324. return new ItemFilter[] { };
  325. }
  326. return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray();
  327. }
  328. /// <summary>
  329. /// Gets the image types.
  330. /// </summary>
  331. /// <returns>IEnumerable{ImageType}.</returns>
  332. public ImageType[] GetImageTypes()
  333. {
  334. var val = ImageTypes;
  335. if (string.IsNullOrEmpty(val))
  336. {
  337. return new ImageType[] { };
  338. }
  339. return val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray();
  340. }
  341. /// <summary>
  342. /// Gets the order by.
  343. /// </summary>
  344. /// <returns>IEnumerable{ItemSortBy}.</returns>
  345. public ValueTuple<string, SortOrder>[] GetOrderBy()
  346. {
  347. return GetOrderBy(SortBy, SortOrder);
  348. }
  349. public static ValueTuple<string, SortOrder>[] GetOrderBy(string sortBy, string requestedSortOrder)
  350. {
  351. var val = sortBy;
  352. if (string.IsNullOrEmpty(val))
  353. {
  354. return Array.Empty<ValueTuple<string, SortOrder>>();
  355. }
  356. var vals = val.Split(',');
  357. if (string.IsNullOrWhiteSpace(requestedSortOrder))
  358. {
  359. requestedSortOrder = "Ascending";
  360. }
  361. var sortOrders = requestedSortOrder.Split(',');
  362. var result = new ValueTuple<string, SortOrder>[vals.Length];
  363. for (var i = 0; i < vals.Length; i++)
  364. {
  365. var sortOrderIndex = sortOrders.Length > i ? i : 0;
  366. var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
  367. var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? MediaBrowser.Model.Entities.SortOrder.Descending : MediaBrowser.Model.Entities.SortOrder.Ascending;
  368. result[i] = new ValueTuple<string, SortOrder>(vals[i], sortOrder);
  369. }
  370. return result;
  371. }
  372. }
  373. }