2
0

LibraryOptions.cs 13 KB

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