LibraryOptions.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. using System;
  2. using System.Collections.Generic;
  3. using MediaBrowser.Model.Entities;
  4. namespace MediaBrowser.Model.Configuration
  5. {
  6. public class LibraryOptions
  7. {
  8. public bool EnablePhotos { get; set; }
  9. public bool EnableRealtimeMonitor { get; set; }
  10. public bool EnableChapterImageExtraction { get; set; }
  11. public bool ExtractChapterImagesDuringLibraryScan { get; set; }
  12. public bool DownloadImagesInAdvance { get; set; }
  13. public MediaPathInfo[] PathInfos { get; set; }
  14. public bool SaveLocalMetadata { get; set; }
  15. public bool EnableInternetProviders { get; set; }
  16. public bool ImportMissingEpisodes { get; set; }
  17. public bool EnableAutomaticSeriesGrouping { get; set; }
  18. public bool EnableEmbeddedTitles { get; set; }
  19. public int AutomaticRefreshIntervalDays { get; set; }
  20. /// <summary>
  21. /// Gets or sets the preferred metadata language.
  22. /// </summary>
  23. /// <value>The preferred metadata language.</value>
  24. public string PreferredMetadataLanguage { get; set; }
  25. /// <summary>
  26. /// Gets or sets the metadata country code.
  27. /// </summary>
  28. /// <value>The metadata country code.</value>
  29. public string MetadataCountryCode { get; set; }
  30. public string SeasonZeroDisplayName { get; set; }
  31. public string[] MetadataSavers { get; set; }
  32. public string[] DisabledLocalMetadataReaders { get; set; }
  33. public string[] LocalMetadataReaderOrder { get; set; }
  34. public string[] DisabledSubtitleFetchers { get; set; }
  35. public string[] SubtitleFetcherOrder { get; set; }
  36. public bool SkipSubtitlesIfEmbeddedSubtitlesPresent { get; set; }
  37. public bool SkipSubtitlesIfAudioTrackMatches { get; set; }
  38. public string[] SubtitleDownloadLanguages { get; set; }
  39. public bool RequirePerfectSubtitleMatch { get; set; }
  40. public bool SaveSubtitlesWithMedia { get; set; }
  41. public TypeOptions[] TypeOptions { get; set; }
  42. public TypeOptions GetTypeOptions(string type)
  43. {
  44. foreach (var options in TypeOptions)
  45. {
  46. if (string.Equals(options.Type, type, StringComparison.OrdinalIgnoreCase))
  47. {
  48. return options;
  49. }
  50. }
  51. return null;
  52. }
  53. public LibraryOptions()
  54. {
  55. TypeOptions = Array.Empty<TypeOptions>();
  56. DisabledSubtitleFetchers = Array.Empty<string>();
  57. SubtitleFetcherOrder = Array.Empty<string>();
  58. DisabledLocalMetadataReaders = Array.Empty<string>();
  59. SkipSubtitlesIfAudioTrackMatches = true;
  60. RequirePerfectSubtitleMatch = true;
  61. EnablePhotos = true;
  62. SaveSubtitlesWithMedia = true;
  63. EnableRealtimeMonitor = true;
  64. PathInfos = Array.Empty<MediaPathInfo>();
  65. EnableInternetProviders = true;
  66. EnableAutomaticSeriesGrouping = true;
  67. SeasonZeroDisplayName = "Specials";
  68. }
  69. }
  70. public class MediaPathInfo
  71. {
  72. public string Path { get; set; }
  73. public string NetworkPath { get; set; }
  74. }
  75. public class TypeOptions
  76. {
  77. public string Type { get; set; }
  78. public string[] MetadataFetchers { get; set; }
  79. public string[] MetadataFetcherOrder { get; set; }
  80. public string[] ImageFetchers { get; set; }
  81. public string[] ImageFetcherOrder { get; set; }
  82. public ImageOption[] ImageOptions { get; set; }
  83. public ImageOption GetImageOptions(ImageType type)
  84. {
  85. foreach (var i in ImageOptions)
  86. {
  87. if (i.Type == type)
  88. {
  89. return i;
  90. }
  91. }
  92. if (DefaultImageOptions.TryGetValue(Type, out ImageOption[] options))
  93. {
  94. foreach (var i in options)
  95. {
  96. if (i.Type == type)
  97. {
  98. return i;
  99. }
  100. }
  101. }
  102. return DefaultInstance;
  103. }
  104. public int GetLimit(ImageType type)
  105. {
  106. return GetImageOptions(type).Limit;
  107. }
  108. public int GetMinWidth(ImageType type)
  109. {
  110. return GetImageOptions(type).MinWidth;
  111. }
  112. public bool IsEnabled(ImageType type)
  113. {
  114. return GetLimit(type) > 0;
  115. }
  116. public TypeOptions()
  117. {
  118. MetadataFetchers = Array.Empty<string>();
  119. MetadataFetcherOrder = Array.Empty<string>();
  120. ImageFetchers = Array.Empty<string>();
  121. ImageFetcherOrder = Array.Empty<string>();
  122. ImageOptions = Array.Empty<ImageOption>();
  123. }
  124. public static Dictionary<string, ImageOption[]> DefaultImageOptions = new Dictionary<string, ImageOption[]>
  125. {
  126. {
  127. "Movie", new []
  128. {
  129. new ImageOption
  130. {
  131. Limit = 1,
  132. MinWidth = 1280,
  133. Type = ImageType.Backdrop
  134. },
  135. // Don't download this by default as it's rarely used.
  136. new ImageOption
  137. {
  138. Limit = 0,
  139. Type = ImageType.Art
  140. },
  141. // Don't download this by default as it's rarely used.
  142. new ImageOption
  143. {
  144. Limit = 0,
  145. Type = ImageType.Disc
  146. },
  147. new ImageOption
  148. {
  149. Limit = 1,
  150. Type = ImageType.Primary
  151. },
  152. new ImageOption
  153. {
  154. Limit = 0,
  155. Type = ImageType.Banner
  156. },
  157. new ImageOption
  158. {
  159. Limit = 1,
  160. Type = ImageType.Thumb
  161. },
  162. new ImageOption
  163. {
  164. Limit = 1,
  165. Type = ImageType.Logo
  166. }
  167. }
  168. },
  169. {
  170. "MusicVideo", new []
  171. {
  172. new ImageOption
  173. {
  174. Limit = 1,
  175. MinWidth = 1280,
  176. Type = ImageType.Backdrop
  177. },
  178. // Don't download this by default as it's rarely used.
  179. new ImageOption
  180. {
  181. Limit = 0,
  182. Type = ImageType.Art
  183. },
  184. // Don't download this by default as it's rarely used.
  185. new ImageOption
  186. {
  187. Limit = 0,
  188. Type = ImageType.Disc
  189. },
  190. new ImageOption
  191. {
  192. Limit = 1,
  193. Type = ImageType.Primary
  194. },
  195. new ImageOption
  196. {
  197. Limit = 0,
  198. Type = ImageType.Banner
  199. },
  200. new ImageOption
  201. {
  202. Limit = 1,
  203. Type = ImageType.Thumb
  204. },
  205. new ImageOption
  206. {
  207. Limit = 1,
  208. Type = ImageType.Logo
  209. }
  210. }
  211. },
  212. {
  213. "Series", new []
  214. {
  215. new ImageOption
  216. {
  217. Limit = 1,
  218. MinWidth = 1280,
  219. Type = ImageType.Backdrop
  220. },
  221. // Don't download this by default as it's rarely used.
  222. new ImageOption
  223. {
  224. Limit = 0,
  225. Type = ImageType.Art
  226. },
  227. new ImageOption
  228. {
  229. Limit = 1,
  230. Type = ImageType.Primary
  231. },
  232. new ImageOption
  233. {
  234. Limit = 1,
  235. Type = ImageType.Banner
  236. },
  237. new ImageOption
  238. {
  239. Limit = 1,
  240. Type = ImageType.Thumb
  241. },
  242. new ImageOption
  243. {
  244. Limit = 1,
  245. Type = ImageType.Logo
  246. }
  247. }
  248. },
  249. {
  250. "MusicAlbum", new []
  251. {
  252. new ImageOption
  253. {
  254. Limit = 0,
  255. MinWidth = 1280,
  256. Type = ImageType.Backdrop
  257. },
  258. // Don't download this by default as it's rarely used.
  259. new ImageOption
  260. {
  261. Limit = 0,
  262. Type = ImageType.Disc
  263. }
  264. }
  265. },
  266. {
  267. "MusicArtist", new []
  268. {
  269. new ImageOption
  270. {
  271. Limit = 1,
  272. MinWidth = 1280,
  273. Type = ImageType.Backdrop
  274. },
  275. // Don't download this by default
  276. // They do look great, but most artists won't have them, which means a banner view isn't really possible
  277. new ImageOption
  278. {
  279. Limit = 0,
  280. Type = ImageType.Banner
  281. },
  282. // Don't download this by default
  283. // Generally not used
  284. new ImageOption
  285. {
  286. Limit = 0,
  287. Type = ImageType.Art
  288. },
  289. new ImageOption
  290. {
  291. Limit = 1,
  292. Type = ImageType.Logo
  293. }
  294. }
  295. },
  296. {
  297. "BoxSet", new []
  298. {
  299. new ImageOption
  300. {
  301. Limit = 1,
  302. MinWidth = 1280,
  303. Type = ImageType.Backdrop
  304. },
  305. new ImageOption
  306. {
  307. Limit = 1,
  308. Type = ImageType.Primary
  309. },
  310. new ImageOption
  311. {
  312. Limit = 1,
  313. Type = ImageType.Thumb
  314. },
  315. new ImageOption
  316. {
  317. Limit = 1,
  318. Type = ImageType.Logo
  319. },
  320. // Don't download this by default as it's rarely used.
  321. new ImageOption
  322. {
  323. Limit = 0,
  324. Type = ImageType.Art
  325. },
  326. // Don't download this by default as it's rarely used.
  327. new ImageOption
  328. {
  329. Limit = 0,
  330. Type = ImageType.Disc
  331. },
  332. // Don't download this by default as it's rarely used.
  333. new ImageOption
  334. {
  335. Limit = 0,
  336. Type = ImageType.Banner
  337. }
  338. }
  339. },
  340. {
  341. "Season", new []
  342. {
  343. new ImageOption
  344. {
  345. Limit = 0,
  346. MinWidth = 1280,
  347. Type = ImageType.Backdrop
  348. },
  349. new ImageOption
  350. {
  351. Limit = 1,
  352. Type = ImageType.Primary
  353. },
  354. new ImageOption
  355. {
  356. Limit = 0,
  357. Type = ImageType.Banner
  358. },
  359. new ImageOption
  360. {
  361. Limit = 0,
  362. Type = ImageType.Thumb
  363. }
  364. }
  365. },
  366. {
  367. "Episode", new []
  368. {
  369. new ImageOption
  370. {
  371. Limit = 0,
  372. MinWidth = 1280,
  373. Type = ImageType.Backdrop
  374. },
  375. new ImageOption
  376. {
  377. Limit = 1,
  378. Type = ImageType.Primary
  379. }
  380. }
  381. }
  382. };
  383. public static ImageOption DefaultInstance = new ImageOption();
  384. }
  385. }