ServerApplicationPaths.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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. }
  130. }
  131. /// <summary>
  132. /// The _people path
  133. /// </summary>
  134. private string _peoplePath;
  135. /// <summary>
  136. /// Gets the path to the People directory
  137. /// </summary>
  138. /// <value>The people path.</value>
  139. public string PeoplePath
  140. {
  141. get
  142. {
  143. if (_peoplePath == null)
  144. {
  145. _peoplePath = Path.Combine(ItemsByNamePath, "People");
  146. if (!Directory.Exists(_peoplePath))
  147. {
  148. Directory.CreateDirectory(_peoplePath);
  149. }
  150. }
  151. return _peoplePath;
  152. }
  153. }
  154. /// <summary>
  155. /// The _genre path
  156. /// </summary>
  157. private string _genrePath;
  158. /// <summary>
  159. /// Gets the path to the Genre directory
  160. /// </summary>
  161. /// <value>The genre path.</value>
  162. public string GenrePath
  163. {
  164. get
  165. {
  166. if (_genrePath == null)
  167. {
  168. _genrePath = Path.Combine(ItemsByNamePath, "Genre");
  169. if (!Directory.Exists(_genrePath))
  170. {
  171. Directory.CreateDirectory(_genrePath);
  172. }
  173. }
  174. return _genrePath;
  175. }
  176. }
  177. /// <summary>
  178. /// The _studio path
  179. /// </summary>
  180. private string _studioPath;
  181. /// <summary>
  182. /// Gets the path to the Studio directory
  183. /// </summary>
  184. /// <value>The studio path.</value>
  185. public string StudioPath
  186. {
  187. get
  188. {
  189. if (_studioPath == null)
  190. {
  191. _studioPath = Path.Combine(ItemsByNamePath, "Studio");
  192. if (!Directory.Exists(_studioPath))
  193. {
  194. Directory.CreateDirectory(_studioPath);
  195. }
  196. }
  197. return _studioPath;
  198. }
  199. }
  200. /// <summary>
  201. /// The _year path
  202. /// </summary>
  203. private string _yearPath;
  204. /// <summary>
  205. /// Gets the path to the Year directory
  206. /// </summary>
  207. /// <value>The year path.</value>
  208. public string YearPath
  209. {
  210. get
  211. {
  212. if (_yearPath == null)
  213. {
  214. _yearPath = Path.Combine(ItemsByNamePath, "Year");
  215. if (!Directory.Exists(_yearPath))
  216. {
  217. Directory.CreateDirectory(_yearPath);
  218. }
  219. }
  220. return _yearPath;
  221. }
  222. }
  223. /// <summary>
  224. /// The _general path
  225. /// </summary>
  226. private string _generalPath;
  227. /// <summary>
  228. /// Gets the path to the General IBN directory
  229. /// </summary>
  230. /// <value>The general path.</value>
  231. public string GeneralPath
  232. {
  233. get
  234. {
  235. if (_generalPath == null)
  236. {
  237. _generalPath = Path.Combine(ItemsByNamePath, "General");
  238. if (!Directory.Exists(_generalPath))
  239. {
  240. Directory.CreateDirectory(_generalPath);
  241. }
  242. }
  243. return _generalPath;
  244. }
  245. }
  246. /// <summary>
  247. /// The _ratings path
  248. /// </summary>
  249. private string _ratingsPath;
  250. /// <summary>
  251. /// Gets the path to the Ratings IBN directory
  252. /// </summary>
  253. /// <value>The ratings path.</value>
  254. public string RatingsPath
  255. {
  256. get
  257. {
  258. if (_ratingsPath == null)
  259. {
  260. _ratingsPath = Path.Combine(ItemsByNamePath, "Ratings");
  261. if (!Directory.Exists(_ratingsPath))
  262. {
  263. Directory.CreateDirectory(_ratingsPath);
  264. }
  265. }
  266. return _ratingsPath;
  267. }
  268. }
  269. /// <summary>
  270. /// The _user configuration directory path
  271. /// </summary>
  272. private string _userConfigurationDirectoryPath;
  273. /// <summary>
  274. /// Gets the path to the user configuration directory
  275. /// </summary>
  276. /// <value>The user configuration directory path.</value>
  277. public string UserConfigurationDirectoryPath
  278. {
  279. get
  280. {
  281. if (_userConfigurationDirectoryPath == null)
  282. {
  283. _userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "users");
  284. if (!Directory.Exists(_userConfigurationDirectoryPath))
  285. {
  286. Directory.CreateDirectory(_userConfigurationDirectoryPath);
  287. }
  288. }
  289. return _userConfigurationDirectoryPath;
  290. }
  291. }
  292. /// <summary>
  293. /// The _f F MPEG stream cache path
  294. /// </summary>
  295. private string _fFMpegStreamCachePath;
  296. /// <summary>
  297. /// Gets the FF MPEG stream cache path.
  298. /// </summary>
  299. /// <value>The FF MPEG stream cache path.</value>
  300. public string EncodedMediaCachePath
  301. {
  302. get
  303. {
  304. if (_fFMpegStreamCachePath == null)
  305. {
  306. _fFMpegStreamCachePath = Path.Combine(CachePath, "encoded-media");
  307. if (!Directory.Exists(_fFMpegStreamCachePath))
  308. {
  309. Directory.CreateDirectory(_fFMpegStreamCachePath);
  310. }
  311. }
  312. return _fFMpegStreamCachePath;
  313. }
  314. }
  315. /// <summary>
  316. /// The _images data path
  317. /// </summary>
  318. private string _downloadedImagesDataPath;
  319. /// <summary>
  320. /// Gets the images data path.
  321. /// </summary>
  322. /// <value>The images data path.</value>
  323. public string DownloadedImagesDataPath
  324. {
  325. get
  326. {
  327. if (_downloadedImagesDataPath == null)
  328. {
  329. _downloadedImagesDataPath = Path.Combine(DataPath, "remote-images");
  330. if (!Directory.Exists(_downloadedImagesDataPath))
  331. {
  332. Directory.CreateDirectory(_downloadedImagesDataPath);
  333. }
  334. }
  335. return _downloadedImagesDataPath;
  336. }
  337. }
  338. /// <summary>
  339. /// The _music artists path
  340. /// </summary>
  341. private string _musicArtistsPath;
  342. /// <summary>
  343. /// Gets the artists path.
  344. /// </summary>
  345. /// <value>The artists path.</value>
  346. public string ArtistsPath
  347. {
  348. get
  349. {
  350. if (_musicArtistsPath == null)
  351. {
  352. _musicArtistsPath = Path.Combine(ItemsByNamePath, "Artists");
  353. if (!Directory.Exists(_musicArtistsPath))
  354. {
  355. Directory.CreateDirectory(_musicArtistsPath);
  356. }
  357. }
  358. return _musicArtistsPath;
  359. }
  360. }
  361. }
  362. }