TypeOptions.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Collections.Generic;
  5. using MediaBrowser.Model.Entities;
  6. namespace MediaBrowser.Model.Configuration
  7. {
  8. public class TypeOptions
  9. {
  10. public static readonly ImageOption DefaultInstance = new ImageOption();
  11. public static readonly Dictionary<string, ImageOption[]> DefaultImageOptions = new Dictionary<string, ImageOption[]>
  12. {
  13. {
  14. "Movie", new[]
  15. {
  16. new ImageOption
  17. {
  18. Limit = 1,
  19. MinWidth = 1280,
  20. Type = ImageType.Backdrop
  21. },
  22. // Don't download this by default as it's rarely used.
  23. new ImageOption
  24. {
  25. Limit = 0,
  26. Type = ImageType.Art
  27. },
  28. // Don't download this by default as it's rarely used.
  29. new ImageOption
  30. {
  31. Limit = 0,
  32. Type = ImageType.Disc
  33. },
  34. new ImageOption
  35. {
  36. Limit = 1,
  37. Type = ImageType.Primary
  38. },
  39. new ImageOption
  40. {
  41. Limit = 0,
  42. Type = ImageType.Banner
  43. },
  44. new ImageOption
  45. {
  46. Limit = 1,
  47. Type = ImageType.Thumb
  48. },
  49. new ImageOption
  50. {
  51. Limit = 1,
  52. Type = ImageType.Logo
  53. }
  54. }
  55. },
  56. {
  57. "MusicVideo", new[]
  58. {
  59. new ImageOption
  60. {
  61. Limit = 1,
  62. MinWidth = 1280,
  63. Type = ImageType.Backdrop
  64. },
  65. // Don't download this by default as it's rarely used.
  66. new ImageOption
  67. {
  68. Limit = 0,
  69. Type = ImageType.Art
  70. },
  71. // Don't download this by default as it's rarely used.
  72. new ImageOption
  73. {
  74. Limit = 0,
  75. Type = ImageType.Disc
  76. },
  77. new ImageOption
  78. {
  79. Limit = 1,
  80. Type = ImageType.Primary
  81. },
  82. new ImageOption
  83. {
  84. Limit = 0,
  85. Type = ImageType.Banner
  86. },
  87. new ImageOption
  88. {
  89. Limit = 1,
  90. Type = ImageType.Thumb
  91. },
  92. new ImageOption
  93. {
  94. Limit = 1,
  95. Type = ImageType.Logo
  96. }
  97. }
  98. },
  99. {
  100. "Series", new[]
  101. {
  102. new ImageOption
  103. {
  104. Limit = 1,
  105. MinWidth = 1280,
  106. Type = ImageType.Backdrop
  107. },
  108. // Don't download this by default as it's rarely used.
  109. new ImageOption
  110. {
  111. Limit = 0,
  112. Type = ImageType.Art
  113. },
  114. new ImageOption
  115. {
  116. Limit = 1,
  117. Type = ImageType.Primary
  118. },
  119. new ImageOption
  120. {
  121. Limit = 1,
  122. Type = ImageType.Banner
  123. },
  124. new ImageOption
  125. {
  126. Limit = 1,
  127. Type = ImageType.Thumb
  128. },
  129. new ImageOption
  130. {
  131. Limit = 1,
  132. Type = ImageType.Logo
  133. }
  134. }
  135. },
  136. {
  137. "MusicAlbum", new[]
  138. {
  139. new ImageOption
  140. {
  141. Limit = 0,
  142. MinWidth = 1280,
  143. Type = ImageType.Backdrop
  144. },
  145. // Don't download this by default as it's rarely used.
  146. new ImageOption
  147. {
  148. Limit = 0,
  149. Type = ImageType.Disc
  150. }
  151. }
  152. },
  153. {
  154. "MusicArtist", new[]
  155. {
  156. new ImageOption
  157. {
  158. Limit = 1,
  159. MinWidth = 1280,
  160. Type = ImageType.Backdrop
  161. },
  162. // Don't download this by default
  163. // They do look great, but most artists won't have them, which means a banner view isn't really possible
  164. new ImageOption
  165. {
  166. Limit = 0,
  167. Type = ImageType.Banner
  168. },
  169. // Don't download this by default
  170. // Generally not used
  171. new ImageOption
  172. {
  173. Limit = 0,
  174. Type = ImageType.Art
  175. },
  176. new ImageOption
  177. {
  178. Limit = 1,
  179. Type = ImageType.Logo
  180. }
  181. }
  182. },
  183. {
  184. "BoxSet", new[]
  185. {
  186. new ImageOption
  187. {
  188. Limit = 1,
  189. MinWidth = 1280,
  190. Type = ImageType.Backdrop
  191. },
  192. new ImageOption
  193. {
  194. Limit = 1,
  195. Type = ImageType.Primary
  196. },
  197. new ImageOption
  198. {
  199. Limit = 1,
  200. Type = ImageType.Thumb
  201. },
  202. new ImageOption
  203. {
  204. Limit = 1,
  205. Type = ImageType.Logo
  206. },
  207. // Don't download this by default as it's rarely used.
  208. new ImageOption
  209. {
  210. Limit = 0,
  211. Type = ImageType.Art
  212. },
  213. // Don't download this by default as it's rarely used.
  214. new ImageOption
  215. {
  216. Limit = 0,
  217. Type = ImageType.Disc
  218. },
  219. // Don't download this by default as it's rarely used.
  220. new ImageOption
  221. {
  222. Limit = 0,
  223. Type = ImageType.Banner
  224. }
  225. }
  226. },
  227. {
  228. "Season", new[]
  229. {
  230. new ImageOption
  231. {
  232. Limit = 0,
  233. MinWidth = 1280,
  234. Type = ImageType.Backdrop
  235. },
  236. new ImageOption
  237. {
  238. Limit = 1,
  239. Type = ImageType.Primary
  240. },
  241. new ImageOption
  242. {
  243. Limit = 0,
  244. Type = ImageType.Banner
  245. },
  246. new ImageOption
  247. {
  248. Limit = 0,
  249. Type = ImageType.Thumb
  250. }
  251. }
  252. },
  253. {
  254. "Episode", new[]
  255. {
  256. new ImageOption
  257. {
  258. Limit = 0,
  259. MinWidth = 1280,
  260. Type = ImageType.Backdrop
  261. },
  262. new ImageOption
  263. {
  264. Limit = 1,
  265. Type = ImageType.Primary
  266. }
  267. }
  268. }
  269. };
  270. public TypeOptions()
  271. {
  272. MetadataFetchers = Array.Empty<string>();
  273. MetadataFetcherOrder = Array.Empty<string>();
  274. ImageFetchers = Array.Empty<string>();
  275. ImageFetcherOrder = Array.Empty<string>();
  276. ImageOptions = Array.Empty<ImageOption>();
  277. }
  278. public string Type { get; set; }
  279. public string[] MetadataFetchers { get; set; }
  280. public string[] MetadataFetcherOrder { get; set; }
  281. public string[] ImageFetchers { get; set; }
  282. public string[] ImageFetcherOrder { get; set; }
  283. public ImageOption[] ImageOptions { get; set; }
  284. public ImageOption GetImageOptions(ImageType type)
  285. {
  286. foreach (var i in ImageOptions)
  287. {
  288. if (i.Type == type)
  289. {
  290. return i;
  291. }
  292. }
  293. if (DefaultImageOptions.TryGetValue(Type, out ImageOption[] options))
  294. {
  295. foreach (var i in options)
  296. {
  297. if (i.Type == type)
  298. {
  299. return i;
  300. }
  301. }
  302. }
  303. return DefaultInstance;
  304. }
  305. public int GetLimit(ImageType type)
  306. {
  307. return GetImageOptions(type).Limit;
  308. }
  309. public int GetMinWidth(ImageType type)
  310. {
  311. return GetImageOptions(type).MinWidth;
  312. }
  313. public bool IsEnabled(ImageType type)
  314. {
  315. return GetLimit(type) > 0;
  316. }
  317. }
  318. }