LibraryOptions.cs 13 KB

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