ServerApplicationPaths.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. using MediaBrowser.Common.Implementations;
  2. using MediaBrowser.Controller;
  3. using System.IO;
  4. namespace MediaBrowser.Server.Implementations
  5. {
  6. /// <summary>
  7. /// Extends BaseApplicationPaths to add paths that are only applicable on the server
  8. /// </summary>
  9. public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
  10. {
  11. #if (DEBUG)
  12. /// <summary>
  13. /// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class.
  14. /// </summary>
  15. public ServerApplicationPaths()
  16. : base(true)
  17. {
  18. }
  19. #else
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="ServerApplicationPaths"/> class.
  22. /// </summary>
  23. public ServerApplicationPaths()
  24. : base(false)
  25. {
  26. }
  27. #endif
  28. /// <summary>
  29. /// The _root folder path
  30. /// </summary>
  31. private string _rootFolderPath;
  32. /// <summary>
  33. /// Gets the path to the base root media directory
  34. /// </summary>
  35. /// <value>The root folder path.</value>
  36. public string RootFolderPath
  37. {
  38. get
  39. {
  40. if (_rootFolderPath == null)
  41. {
  42. _rootFolderPath = Path.Combine(ProgramDataPath, "Root");
  43. if (!Directory.Exists(_rootFolderPath))
  44. {
  45. Directory.CreateDirectory(_rootFolderPath);
  46. }
  47. }
  48. return _rootFolderPath;
  49. }
  50. }
  51. /// <summary>
  52. /// The _default user views path
  53. /// </summary>
  54. private string _defaultUserViewsPath;
  55. /// <summary>
  56. /// Gets the path to the default user view directory. Used if no specific user view is defined.
  57. /// </summary>
  58. /// <value>The default user views path.</value>
  59. public string DefaultUserViewsPath
  60. {
  61. get
  62. {
  63. if (_defaultUserViewsPath == null)
  64. {
  65. _defaultUserViewsPath = Path.Combine(RootFolderPath, "Default");
  66. if (!Directory.Exists(_defaultUserViewsPath))
  67. {
  68. Directory.CreateDirectory(_defaultUserViewsPath);
  69. }
  70. }
  71. return _defaultUserViewsPath;
  72. }
  73. }
  74. /// <summary>
  75. /// The _localization path
  76. /// </summary>
  77. private string _localizationPath;
  78. /// <summary>
  79. /// Gets the path to localization data.
  80. /// </summary>
  81. /// <value>The localization path.</value>
  82. public string LocalizationPath
  83. {
  84. get
  85. {
  86. if (_localizationPath == null)
  87. {
  88. _localizationPath = Path.Combine(ProgramDataPath, "Localization");
  89. if (!Directory.Exists(_localizationPath))
  90. {
  91. Directory.CreateDirectory(_localizationPath);
  92. }
  93. }
  94. return _localizationPath;
  95. }
  96. }
  97. /// <summary>
  98. /// The _ibn path
  99. /// </summary>
  100. private string _ibnPath;
  101. /// <summary>
  102. /// Gets the path to the Images By Name directory
  103. /// </summary>
  104. /// <value>The images by name path.</value>
  105. public string ItemsByNamePath
  106. {
  107. get
  108. {
  109. if (_ibnPath == null)
  110. {
  111. _ibnPath = Path.Combine(ProgramDataPath, "ImagesByName");
  112. if (!Directory.Exists(_ibnPath))
  113. {
  114. Directory.CreateDirectory(_ibnPath);
  115. }
  116. }
  117. return _ibnPath;
  118. }
  119. set
  120. {
  121. _ibnPath = value;
  122. _peoplePath = null;
  123. _studioPath = null;
  124. _genrePath = null;
  125. _yearPath = null;
  126. _musicArtistsPath = null;
  127. _generalPath = null;
  128. _ratingsPath = null;
  129. _mediaInfoImagesPath = null;
  130. }
  131. }
  132. /// <summary>
  133. /// The _people path
  134. /// </summary>
  135. private string _peoplePath;
  136. /// <summary>
  137. /// Gets the path to the People directory
  138. /// </summary>
  139. /// <value>The people path.</value>
  140. public string PeoplePath
  141. {
  142. get
  143. {
  144. if (_peoplePath == null)
  145. {
  146. _peoplePath = Path.Combine(ItemsByNamePath, "People");
  147. if (!Directory.Exists(_peoplePath))
  148. {
  149. Directory.CreateDirectory(_peoplePath);
  150. }
  151. }
  152. return _peoplePath;
  153. }
  154. }
  155. /// <summary>
  156. /// The _genre path
  157. /// </summary>
  158. private string _genrePath;
  159. /// <summary>
  160. /// Gets the path to the Genre directory
  161. /// </summary>
  162. /// <value>The genre path.</value>
  163. public string GenrePath
  164. {
  165. get
  166. {
  167. if (_genrePath == null)
  168. {
  169. _genrePath = Path.Combine(ItemsByNamePath, "Genre");
  170. if (!Directory.Exists(_genrePath))
  171. {
  172. Directory.CreateDirectory(_genrePath);
  173. }
  174. }
  175. return _genrePath;
  176. }
  177. }
  178. /// <summary>
  179. /// The _studio path
  180. /// </summary>
  181. private string _studioPath;
  182. /// <summary>
  183. /// Gets the path to the Studio directory
  184. /// </summary>
  185. /// <value>The studio path.</value>
  186. public string StudioPath
  187. {
  188. get
  189. {
  190. if (_studioPath == null)
  191. {
  192. _studioPath = Path.Combine(ItemsByNamePath, "Studio");
  193. if (!Directory.Exists(_studioPath))
  194. {
  195. Directory.CreateDirectory(_studioPath);
  196. }
  197. }
  198. return _studioPath;
  199. }
  200. }
  201. /// <summary>
  202. /// The _year path
  203. /// </summary>
  204. private string _yearPath;
  205. /// <summary>
  206. /// Gets the path to the Year directory
  207. /// </summary>
  208. /// <value>The year path.</value>
  209. public string YearPath
  210. {
  211. get
  212. {
  213. if (_yearPath == null)
  214. {
  215. _yearPath = Path.Combine(ItemsByNamePath, "Year");
  216. if (!Directory.Exists(_yearPath))
  217. {
  218. Directory.CreateDirectory(_yearPath);
  219. }
  220. }
  221. return _yearPath;
  222. }
  223. }
  224. /// <summary>
  225. /// The _general path
  226. /// </summary>
  227. private string _generalPath;
  228. /// <summary>
  229. /// Gets the path to the General IBN directory
  230. /// </summary>
  231. /// <value>The general path.</value>
  232. public string GeneralPath
  233. {
  234. get
  235. {
  236. if (_generalPath == null)
  237. {
  238. _generalPath = Path.Combine(ItemsByNamePath, "General");
  239. if (!Directory.Exists(_generalPath))
  240. {
  241. Directory.CreateDirectory(_generalPath);
  242. }
  243. }
  244. return _generalPath;
  245. }
  246. }
  247. /// <summary>
  248. /// The _ratings path
  249. /// </summary>
  250. private string _ratingsPath;
  251. /// <summary>
  252. /// Gets the path to the Ratings IBN directory
  253. /// </summary>
  254. /// <value>The ratings path.</value>
  255. public string RatingsPath
  256. {
  257. get
  258. {
  259. if (_ratingsPath == null)
  260. {
  261. _ratingsPath = Path.Combine(ItemsByNamePath, "Ratings");
  262. if (!Directory.Exists(_ratingsPath))
  263. {
  264. Directory.CreateDirectory(_ratingsPath);
  265. }
  266. }
  267. return _ratingsPath;
  268. }
  269. }
  270. /// <summary>
  271. /// The _media info images path
  272. /// </summary>
  273. private string _mediaInfoImagesPath;
  274. /// <summary>
  275. /// Gets the media info images path.
  276. /// </summary>
  277. /// <value>The media info images path.</value>
  278. public string MediaInfoImagesPath
  279. {
  280. get
  281. {
  282. if (_mediaInfoImagesPath == null)
  283. {
  284. _mediaInfoImagesPath = Path.Combine(ItemsByNamePath, "MediaInfo");
  285. if (!Directory.Exists(_mediaInfoImagesPath))
  286. {
  287. Directory.CreateDirectory(_mediaInfoImagesPath);
  288. }
  289. }
  290. return _mediaInfoImagesPath;
  291. }
  292. }
  293. /// <summary>
  294. /// The _user configuration directory path
  295. /// </summary>
  296. private string _userConfigurationDirectoryPath;
  297. /// <summary>
  298. /// Gets the path to the user configuration directory
  299. /// </summary>
  300. /// <value>The user configuration directory path.</value>
  301. public string UserConfigurationDirectoryPath
  302. {
  303. get
  304. {
  305. if (_userConfigurationDirectoryPath == null)
  306. {
  307. _userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "users");
  308. if (!Directory.Exists(_userConfigurationDirectoryPath))
  309. {
  310. Directory.CreateDirectory(_userConfigurationDirectoryPath);
  311. }
  312. }
  313. return _userConfigurationDirectoryPath;
  314. }
  315. }
  316. /// <summary>
  317. /// The _f F MPEG stream cache path
  318. /// </summary>
  319. private string _fFMpegStreamCachePath;
  320. /// <summary>
  321. /// Gets the FF MPEG stream cache path.
  322. /// </summary>
  323. /// <value>The FF MPEG stream cache path.</value>
  324. public string EncodedMediaCachePath
  325. {
  326. get
  327. {
  328. if (_fFMpegStreamCachePath == null)
  329. {
  330. _fFMpegStreamCachePath = Path.Combine(CachePath, "encoded-media");
  331. if (!Directory.Exists(_fFMpegStreamCachePath))
  332. {
  333. Directory.CreateDirectory(_fFMpegStreamCachePath);
  334. }
  335. }
  336. return _fFMpegStreamCachePath;
  337. }
  338. }
  339. /// <summary>
  340. /// The _images data path
  341. /// </summary>
  342. private string _downloadedImagesDataPath;
  343. /// <summary>
  344. /// Gets the images data path.
  345. /// </summary>
  346. /// <value>The images data path.</value>
  347. public string DownloadedImagesDataPath
  348. {
  349. get
  350. {
  351. if (_downloadedImagesDataPath == null)
  352. {
  353. _downloadedImagesDataPath = Path.Combine(DataPath, "remote-images");
  354. if (!Directory.Exists(_downloadedImagesDataPath))
  355. {
  356. Directory.CreateDirectory(_downloadedImagesDataPath);
  357. }
  358. }
  359. return _downloadedImagesDataPath;
  360. }
  361. }
  362. /// <summary>
  363. /// The _music artists path
  364. /// </summary>
  365. private string _musicArtistsPath;
  366. /// <summary>
  367. /// Gets the artists path.
  368. /// </summary>
  369. /// <value>The artists path.</value>
  370. public string ArtistsPath
  371. {
  372. get
  373. {
  374. if (_musicArtistsPath == null)
  375. {
  376. _musicArtistsPath = Path.Combine(ItemsByNamePath, "Artists");
  377. if (!Directory.Exists(_musicArtistsPath))
  378. {
  379. Directory.CreateDirectory(_musicArtistsPath);
  380. }
  381. }
  382. return _musicArtistsPath;
  383. }
  384. }
  385. }
  386. }