BaseItemsRequest.cs 28 KB

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