ReportRequests.cs 17 KB

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