ServerApplicationPaths.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. using MediaBrowser.Common.Kernel;
  2. using System.IO;
  3. namespace MediaBrowser.Controller
  4. {
  5. /// <summary>
  6. /// Extends BaseApplicationPaths to add paths that are only applicable on the server
  7. /// </summary>
  8. public class ServerApplicationPaths : BaseApplicationPaths
  9. {
  10. /// <summary>
  11. /// The _root folder path
  12. /// </summary>
  13. private string _rootFolderPath;
  14. /// <summary>
  15. /// Gets the path to the base root media directory
  16. /// </summary>
  17. /// <value>The root folder path.</value>
  18. public string RootFolderPath
  19. {
  20. get
  21. {
  22. if (_rootFolderPath == null)
  23. {
  24. _rootFolderPath = Path.Combine(ProgramDataPath, "Root");
  25. if (!Directory.Exists(_rootFolderPath))
  26. {
  27. Directory.CreateDirectory(_rootFolderPath);
  28. }
  29. }
  30. return _rootFolderPath;
  31. }
  32. }
  33. /// <summary>
  34. /// The _default user views path
  35. /// </summary>
  36. private string _defaultUserViewsPath;
  37. /// <summary>
  38. /// Gets the path to the default user view directory. Used if no specific user view is defined.
  39. /// </summary>
  40. /// <value>The default user views path.</value>
  41. public string DefaultUserViewsPath
  42. {
  43. get
  44. {
  45. if (_defaultUserViewsPath == null)
  46. {
  47. _defaultUserViewsPath = Path.Combine(RootFolderPath, "Default");
  48. if (!Directory.Exists(_defaultUserViewsPath))
  49. {
  50. Directory.CreateDirectory(_defaultUserViewsPath);
  51. }
  52. }
  53. return _defaultUserViewsPath;
  54. }
  55. }
  56. /// <summary>
  57. /// The _localization path
  58. /// </summary>
  59. private string _localizationPath;
  60. /// <summary>
  61. /// Gets the path to localization data.
  62. /// </summary>
  63. /// <value>The localization path.</value>
  64. public string LocalizationPath
  65. {
  66. get
  67. {
  68. if (_localizationPath == null)
  69. {
  70. _localizationPath = Path.Combine(ProgramDataPath, "Localization");
  71. if (!Directory.Exists(_localizationPath))
  72. {
  73. Directory.CreateDirectory(_localizationPath);
  74. }
  75. }
  76. return _localizationPath;
  77. }
  78. }
  79. /// <summary>
  80. /// The _ibn path
  81. /// </summary>
  82. private string _ibnPath;
  83. /// <summary>
  84. /// Gets the path to the Images By Name directory
  85. /// </summary>
  86. /// <value>The images by name path.</value>
  87. public string ImagesByNamePath
  88. {
  89. get
  90. {
  91. if (_ibnPath == null)
  92. {
  93. _ibnPath = Path.Combine(ProgramDataPath, "ImagesByName");
  94. if (!Directory.Exists(_ibnPath))
  95. {
  96. Directory.CreateDirectory(_ibnPath);
  97. }
  98. }
  99. return _ibnPath;
  100. }
  101. }
  102. /// <summary>
  103. /// The _people path
  104. /// </summary>
  105. private string _peoplePath;
  106. /// <summary>
  107. /// Gets the path to the People directory
  108. /// </summary>
  109. /// <value>The people path.</value>
  110. public string PeoplePath
  111. {
  112. get
  113. {
  114. if (_peoplePath == null)
  115. {
  116. _peoplePath = Path.Combine(ImagesByNamePath, "People");
  117. if (!Directory.Exists(_peoplePath))
  118. {
  119. Directory.CreateDirectory(_peoplePath);
  120. }
  121. }
  122. return _peoplePath;
  123. }
  124. }
  125. /// <summary>
  126. /// The _genre path
  127. /// </summary>
  128. private string _genrePath;
  129. /// <summary>
  130. /// Gets the path to the Genre directory
  131. /// </summary>
  132. /// <value>The genre path.</value>
  133. public string GenrePath
  134. {
  135. get
  136. {
  137. if (_genrePath == null)
  138. {
  139. _genrePath = Path.Combine(ImagesByNamePath, "Genre");
  140. if (!Directory.Exists(_genrePath))
  141. {
  142. Directory.CreateDirectory(_genrePath);
  143. }
  144. }
  145. return _genrePath;
  146. }
  147. }
  148. /// <summary>
  149. /// The _studio path
  150. /// </summary>
  151. private string _studioPath;
  152. /// <summary>
  153. /// Gets the path to the Studio directory
  154. /// </summary>
  155. /// <value>The studio path.</value>
  156. public string StudioPath
  157. {
  158. get
  159. {
  160. if (_studioPath == null)
  161. {
  162. _studioPath = Path.Combine(ImagesByNamePath, "Studio");
  163. if (!Directory.Exists(_studioPath))
  164. {
  165. Directory.CreateDirectory(_studioPath);
  166. }
  167. }
  168. return _studioPath;
  169. }
  170. }
  171. /// <summary>
  172. /// The _year path
  173. /// </summary>
  174. private string _yearPath;
  175. /// <summary>
  176. /// Gets the path to the Year directory
  177. /// </summary>
  178. /// <value>The year path.</value>
  179. public string YearPath
  180. {
  181. get
  182. {
  183. if (_yearPath == null)
  184. {
  185. _yearPath = Path.Combine(ImagesByNamePath, "Year");
  186. if (!Directory.Exists(_yearPath))
  187. {
  188. Directory.CreateDirectory(_yearPath);
  189. }
  190. }
  191. return _yearPath;
  192. }
  193. }
  194. /// <summary>
  195. /// The _general path
  196. /// </summary>
  197. private string _generalPath;
  198. /// <summary>
  199. /// Gets the path to the General IBN directory
  200. /// </summary>
  201. /// <value>The general path.</value>
  202. public string GeneralPath
  203. {
  204. get
  205. {
  206. if (_generalPath == null)
  207. {
  208. _generalPath = Path.Combine(ImagesByNamePath, "General");
  209. if (!Directory.Exists(_generalPath))
  210. {
  211. Directory.CreateDirectory(_generalPath);
  212. }
  213. }
  214. return _generalPath;
  215. }
  216. }
  217. /// <summary>
  218. /// The _ratings path
  219. /// </summary>
  220. private string _ratingsPath;
  221. /// <summary>
  222. /// Gets the path to the Ratings IBN directory
  223. /// </summary>
  224. /// <value>The ratings path.</value>
  225. public string RatingsPath
  226. {
  227. get
  228. {
  229. if (_ratingsPath == null)
  230. {
  231. _ratingsPath = Path.Combine(ImagesByNamePath, "Ratings");
  232. if (!Directory.Exists(_ratingsPath))
  233. {
  234. Directory.CreateDirectory(_ratingsPath);
  235. }
  236. }
  237. return _ratingsPath;
  238. }
  239. }
  240. /// <summary>
  241. /// The _user configuration directory path
  242. /// </summary>
  243. private string _userConfigurationDirectoryPath;
  244. /// <summary>
  245. /// Gets the path to the user configuration directory
  246. /// </summary>
  247. /// <value>The user configuration directory path.</value>
  248. public string UserConfigurationDirectoryPath
  249. {
  250. get
  251. {
  252. if (_userConfigurationDirectoryPath == null)
  253. {
  254. _userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "users");
  255. if (!Directory.Exists(_userConfigurationDirectoryPath))
  256. {
  257. Directory.CreateDirectory(_userConfigurationDirectoryPath);
  258. }
  259. }
  260. return _userConfigurationDirectoryPath;
  261. }
  262. }
  263. /// <summary>
  264. /// The _f F MPEG stream cache path
  265. /// </summary>
  266. private string _fFMpegStreamCachePath;
  267. /// <summary>
  268. /// Gets the FF MPEG stream cache path.
  269. /// </summary>
  270. /// <value>The FF MPEG stream cache path.</value>
  271. public string FFMpegStreamCachePath
  272. {
  273. get
  274. {
  275. if (_fFMpegStreamCachePath == null)
  276. {
  277. _fFMpegStreamCachePath = Path.Combine(CachePath, "ffmpeg-streams");
  278. if (!Directory.Exists(_fFMpegStreamCachePath))
  279. {
  280. Directory.CreateDirectory(_fFMpegStreamCachePath);
  281. }
  282. }
  283. return _fFMpegStreamCachePath;
  284. }
  285. }
  286. /// <summary>
  287. /// The _media tools path
  288. /// </summary>
  289. private string _mediaToolsPath;
  290. /// <summary>
  291. /// Gets the folder path to tools
  292. /// </summary>
  293. /// <value>The media tools path.</value>
  294. public string MediaToolsPath
  295. {
  296. get
  297. {
  298. if (_mediaToolsPath == null)
  299. {
  300. _mediaToolsPath = Path.Combine(ProgramDataPath, "MediaTools");
  301. if (!Directory.Exists(_mediaToolsPath))
  302. {
  303. Directory.CreateDirectory(_mediaToolsPath);
  304. }
  305. }
  306. return _mediaToolsPath;
  307. }
  308. }
  309. }
  310. }