ReportRequests.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. using MediaBrowser.Api.UserLibrary;
  2. using MediaBrowser.Model.Entities;
  3. using ServiceStack;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace MediaBrowser.Api.Reports
  8. {
  9. public class BaseReportRequest : BaseItemsRequest
  10. {
  11. /// <summary>
  12. /// Gets or sets the user id.
  13. /// </summary>
  14. /// <value>The user id.</value>
  15. [ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
  16. public string UserId { get; set; }
  17. /// <summary>
  18. /// Limit results to items containing a specific person
  19. /// </summary>
  20. /// <value>The person.</value>
  21. [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")]
  22. public string Person { get; set; }
  23. [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")]
  24. public string PersonIds { get; set; }
  25. /// <summary>
  26. /// If the Person filter is used, this can also be used to restrict to a specific person type
  27. /// </summary>
  28. /// <value>The type of the person.</value>
  29. [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")]
  30. public string PersonTypes { get; set; }
  31. /// <summary>
  32. /// Limit results to items containing specific studios
  33. /// </summary>
  34. /// <value>The studios.</value>
  35. [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)]
  36. public string Studios { get; set; }
  37. [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)]
  38. public string StudioIds { get; set; }
  39. /// <summary>
  40. /// Gets or sets the studios.
  41. /// </summary>
  42. /// <value>The studios.</value>
  43. [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)]
  44. public string Artists { get; set; }
  45. [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)]
  46. public string ArtistIds { get; set; }
  47. [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)]
  48. public string Albums { get; set; }
  49. /// <summary>
  50. /// Gets or sets the item ids.
  51. /// </summary>
  52. /// <value>The item ids.</value>
  53. [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)]
  54. public string Ids { get; set; }
  55. public bool HasQueryLimit { get; set; }
  56. public string GroupBy { get; set; }
  57. public string ReportColumns { get; set; }
  58. /// <summary>
  59. /// Gets or sets the video types.
  60. /// </summary>
  61. /// <value>The video types.</value>
  62. [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)]
  63. public string VideoTypes { get; set; }
  64. /// <summary>
  65. /// Gets or sets the video formats.
  66. /// </summary>
  67. /// <value>The video formats.</value>
  68. [ApiMember(Name = "Is3D", Description = "Optional filter by items that are 3D, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  69. public bool? Is3D { get; set; }
  70. /// <summary>
  71. /// Gets or sets the series status.
  72. /// </summary>
  73. /// <value>The series status.</value>
  74. [ApiMember(Name = "SeriesStatus", Description = "Optional filter by Series Status. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  75. public string SeriesStatus { get; set; }
  76. [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")]
  77. public string NameStartsWithOrGreater { get; set; }
  78. [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")]
  79. public string NameStartsWith { get; set; }
  80. [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")]
  81. public string NameLessThan { get; set; }
  82. [ApiMember(Name = "AlbumArtistStartsWithOrGreater", Description = "Optional filter by items whose album artist is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  83. public string AlbumArtistStartsWithOrGreater { get; set; }
  84. /// <summary>
  85. /// Gets or sets the air days.
  86. /// </summary>
  87. /// <value>The air days.</value>
  88. [ApiMember(Name = "AirDays", Description = "Optional filter by Series Air Days. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  89. public string AirDays { get; set; }
  90. /// <summary>
  91. /// Gets or sets the min offical rating.
  92. /// </summary>
  93. /// <value>The min offical rating.</value>
  94. [ApiMember(Name = "MinOfficialRating", Description = "Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  95. public string MinOfficialRating { get; set; }
  96. /// <summary>
  97. /// Gets or sets the max offical rating.
  98. /// </summary>
  99. /// <value>The max offical rating.</value>
  100. [ApiMember(Name = "MaxOfficialRating", Description = "Optional filter by maximum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  101. public string MaxOfficialRating { get; set; }
  102. [ApiMember(Name = "HasThemeSong", Description = "Optional filter by items with theme songs.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  103. public bool? HasThemeSong { get; set; }
  104. [ApiMember(Name = "HasThemeVideo", Description = "Optional filter by items with theme videos.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  105. public bool? HasThemeVideo { get; set; }
  106. [ApiMember(Name = "HasSubtitles", Description = "Optional filter by items with subtitles.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  107. public bool? HasSubtitles { get; set; }
  108. [ApiMember(Name = "HasSpecialFeature", Description = "Optional filter by items with special features.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  109. public bool? HasSpecialFeature { get; set; }
  110. [ApiMember(Name = "HasTrailer", Description = "Optional filter by items with trailers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  111. public bool? HasTrailer { get; set; }
  112. [ApiMember(Name = "AdjacentTo", Description = "Optional. Return items that are siblings of a supplied item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  113. public string AdjacentTo { get; set; }
  114. [ApiMember(Name = "MinIndexNumber", Description = "Optional filter by minimum index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  115. public int? MinIndexNumber { get; set; }
  116. [ApiMember(Name = "MinPlayers", Description = "Optional filter by minimum number of game players.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  117. public int? MinPlayers { get; set; }
  118. [ApiMember(Name = "MaxPlayers", Description = "Optional filter by maximum number of game players.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  119. public int? MaxPlayers { get; set; }
  120. [ApiMember(Name = "ParentIndexNumber", Description = "Optional filter by parent index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  121. public int? ParentIndexNumber { get; set; }
  122. [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")]
  123. public bool? HasParentalRating { get; set; }
  124. [ApiMember(Name = "IsHD", Description = "Optional filter by items that are HD or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  125. public bool? IsHD { get; set; }
  126. [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)]
  127. public string LocationTypes { get; set; }
  128. [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)]
  129. public string ExcludeLocationTypes { get; set; }
  130. [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  131. public bool? IsMissing { get; set; }
  132. [ApiMember(Name = "IsUnaired", Description = "Optional filter by items that are unaired episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  133. public bool? IsUnaired { get; set; }
  134. [ApiMember(Name = "IsVirtualUnaired", Description = "Optional filter by items that are virtual unaired episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  135. public bool? IsVirtualUnaired { get; set; }
  136. [ApiMember(Name = "MinCommunityRating", Description = "Optional filter by minimum community rating.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  137. public double? MinCommunityRating { get; set; }
  138. [ApiMember(Name = "MinCriticRating", Description = "Optional filter by minimum critic rating.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  139. public double? MinCriticRating { get; set; }
  140. [ApiMember(Name = "AiredDuringSeason", Description = "Gets all episodes that aired during a season, including specials.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  141. public int? AiredDuringSeason { get; set; }
  142. [ApiMember(Name = "MinPremiereDate", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
  143. public string MinPremiereDate { get; set; }
  144. [ApiMember(Name = "MaxPremiereDate", Description = "Optional. The maximum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
  145. public string MaxPremiereDate { get; set; }
  146. [ApiMember(Name = "HasOverview", Description = "Optional filter by items that have an overview or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  147. public bool? HasOverview { get; set; }
  148. [ApiMember(Name = "HasImdbId", Description = "Optional filter by items that have an imdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  149. public bool? HasImdbId { get; set; }
  150. [ApiMember(Name = "HasTmdbId", Description = "Optional filter by items that have a tmdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  151. public bool? HasTmdbId { get; set; }
  152. [ApiMember(Name = "HasTvdbId", Description = "Optional filter by items that have a tvdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  153. public bool? HasTvdbId { get; set; }
  154. [ApiMember(Name = "IsYearMismatched", Description = "Optional filter by items that are potentially misidentified.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  155. public bool? IsYearMismatched { get; set; }
  156. [ApiMember(Name = "IsInBoxSet", Description = "Optional filter by items that are in boxsets, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  157. public bool? IsInBoxSet { get; set; }
  158. [ApiMember(Name = "IsLocked", Description = "Optional filter by items that are locked.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  159. public bool? IsLocked { get; set; }
  160. [ApiMember(Name = "IsUnidentified", Description = "Optional filter by items that are unidentified by internet metadata providers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  161. public bool? IsUnidentified { get; set; }
  162. [ApiMember(Name = "IsPlaceHolder", Description = "Optional filter by items that are placeholders", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  163. public bool? IsPlaceHolder { get; set; }
  164. [ApiMember(Name = "HasOfficialRating", Description = "Optional filter by items that have official ratings", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  165. public bool? HasOfficialRating { get; set; }
  166. [ApiMember(Name = "CollapseBoxSetItems", Description = "Whether or not to hide items behind their boxsets.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  167. public bool? CollapseBoxSetItems { get; set; }
  168. public string[] GetStudios()
  169. {
  170. return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  171. }
  172. public string[] GetStudioIds()
  173. {
  174. return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  175. }
  176. public string[] GetPersonTypes()
  177. {
  178. return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  179. }
  180. public string[] GetPersonIds()
  181. {
  182. return (PersonIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  183. }
  184. public VideoType[] GetVideoTypes()
  185. {
  186. var val = VideoTypes;
  187. if (string.IsNullOrEmpty(val))
  188. {
  189. return new VideoType[] { };
  190. }
  191. return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
  192. }
  193. }
  194. [Route("/Reports/Items", "GET", Summary = "Gets reports based on library items")]
  195. public class GetItemReport : BaseReportRequest, IReturn<ReportResult>
  196. {
  197. }
  198. [Route("/Reports/Headers", "GET", Summary = "Gets reports headers based on library items")]
  199. public class GetReportHeaders : BaseReportRequest, IReturn<List<ReportHeader>>
  200. {
  201. }
  202. [Route("/Reports/Statistics", "GET", Summary = "Gets reports statistics based on library items")]
  203. public class GetReportStatistics : BaseReportRequest, IReturn<ReportStatResult>
  204. {
  205. public int? TopItems { get; set; }
  206. }
  207. [Route("/Reports/Items/Download", "GET", Summary = "Downloads report")]
  208. public class GetReportDownload : BaseReportRequest
  209. {
  210. public GetReportDownload()
  211. {
  212. ExportType = ReportExportType.CSV;
  213. }
  214. public ReportExportType ExportType { get; set; }
  215. }
  216. }