2
0

LibraryOptions.cs 13 KB

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