ServerApplicationPaths.cs 9.8 KB

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