ServerApplicationPaths.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. using System.IO;
  2. using MediaBrowser.Common.Kernel;
  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. private string _rootFolderPath;
  11. /// <summary>
  12. /// Gets the path to the root media directory
  13. /// </summary>
  14. public string RootFolderPath
  15. {
  16. get
  17. {
  18. if (_rootFolderPath == null)
  19. {
  20. _rootFolderPath = Path.Combine(ProgramDataPath, "root");
  21. if (!Directory.Exists(_rootFolderPath))
  22. {
  23. Directory.CreateDirectory(_rootFolderPath);
  24. }
  25. }
  26. return _rootFolderPath;
  27. }
  28. }
  29. private string _ibnPath;
  30. /// <summary>
  31. /// Gets the path to the Images By Name directory
  32. /// </summary>
  33. public string ImagesByNamePath
  34. {
  35. get
  36. {
  37. if (_ibnPath == null)
  38. {
  39. _ibnPath = Path.Combine(ProgramDataPath, "ImagesByName");
  40. if (!Directory.Exists(_ibnPath))
  41. {
  42. Directory.CreateDirectory(_ibnPath);
  43. }
  44. }
  45. return _ibnPath;
  46. }
  47. }
  48. private string _PeoplePath;
  49. /// <summary>
  50. /// Gets the path to the People directory
  51. /// </summary>
  52. public string PeoplePath
  53. {
  54. get
  55. {
  56. if (_PeoplePath == null)
  57. {
  58. _PeoplePath = Path.Combine(ImagesByNamePath, "People");
  59. if (!Directory.Exists(_PeoplePath))
  60. {
  61. Directory.CreateDirectory(_PeoplePath);
  62. }
  63. }
  64. return _PeoplePath;
  65. }
  66. }
  67. private string _GenrePath;
  68. /// <summary>
  69. /// Gets the path to the Genre directory
  70. /// </summary>
  71. public string GenrePath
  72. {
  73. get
  74. {
  75. if (_GenrePath == null)
  76. {
  77. _GenrePath = Path.Combine(ImagesByNamePath, "Genre");
  78. if (!Directory.Exists(_GenrePath))
  79. {
  80. Directory.CreateDirectory(_GenrePath);
  81. }
  82. }
  83. return _GenrePath;
  84. }
  85. }
  86. private string _StudioPath;
  87. /// <summary>
  88. /// Gets the path to the Studio directory
  89. /// </summary>
  90. public string StudioPath
  91. {
  92. get
  93. {
  94. if (_StudioPath == null)
  95. {
  96. _StudioPath = Path.Combine(ImagesByNamePath, "Studio");
  97. if (!Directory.Exists(_StudioPath))
  98. {
  99. Directory.CreateDirectory(_StudioPath);
  100. }
  101. }
  102. return _StudioPath;
  103. }
  104. }
  105. private string _yearPath;
  106. /// <summary>
  107. /// Gets the path to the Year directory
  108. /// </summary>
  109. public string YearPath
  110. {
  111. get
  112. {
  113. if (_yearPath == null)
  114. {
  115. _yearPath = Path.Combine(ImagesByNamePath, "Year");
  116. if (!Directory.Exists(_yearPath))
  117. {
  118. Directory.CreateDirectory(_yearPath);
  119. }
  120. }
  121. return _yearPath;
  122. }
  123. }
  124. private string _userConfigurationDirectoryPath;
  125. /// <summary>
  126. /// Gets the path to the user configuration directory
  127. /// </summary>
  128. public string UserConfigurationDirectoryPath
  129. {
  130. get
  131. {
  132. if (_userConfigurationDirectoryPath == null)
  133. {
  134. _userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "user");
  135. if (!Directory.Exists(_userConfigurationDirectoryPath))
  136. {
  137. Directory.CreateDirectory(_userConfigurationDirectoryPath);
  138. }
  139. }
  140. return _userConfigurationDirectoryPath;
  141. }
  142. }
  143. private string _CacheDirectory;
  144. /// <summary>
  145. /// Gets the folder path to the cache directory
  146. /// </summary>
  147. public string CacheDirectory
  148. {
  149. get
  150. {
  151. if (_CacheDirectory == null)
  152. {
  153. _CacheDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.ProgramDataPath, "cache");
  154. if (!Directory.Exists(_CacheDirectory))
  155. {
  156. Directory.CreateDirectory(_CacheDirectory);
  157. }
  158. }
  159. return _CacheDirectory;
  160. }
  161. }
  162. private string _FFProbeAudioCacheDirectory;
  163. /// <summary>
  164. /// Gets the folder path to the ffprobe audio cache directory
  165. /// </summary>
  166. public string FFProbeAudioCacheDirectory
  167. {
  168. get
  169. {
  170. if (_FFProbeAudioCacheDirectory == null)
  171. {
  172. _FFProbeAudioCacheDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.CacheDirectory, "ffprobe-audio");
  173. if (!Directory.Exists(_FFProbeAudioCacheDirectory))
  174. {
  175. Directory.CreateDirectory(_FFProbeAudioCacheDirectory);
  176. }
  177. }
  178. return _FFProbeAudioCacheDirectory;
  179. }
  180. }
  181. private string _FFProbeVideoCacheDirectory;
  182. /// <summary>
  183. /// Gets the folder path to the ffprobe video cache directory
  184. /// </summary>
  185. public string FFProbeVideoCacheDirectory
  186. {
  187. get
  188. {
  189. if (_FFProbeVideoCacheDirectory == null)
  190. {
  191. _FFProbeVideoCacheDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.CacheDirectory, "ffprobe-video");
  192. if (!Directory.Exists(_FFProbeVideoCacheDirectory))
  193. {
  194. Directory.CreateDirectory(_FFProbeVideoCacheDirectory);
  195. }
  196. }
  197. return _FFProbeVideoCacheDirectory;
  198. }
  199. }
  200. private string _FFMpegDirectory;
  201. /// <summary>
  202. /// Gets the folder path to ffmpeg
  203. /// </summary>
  204. public string FFMpegDirectory
  205. {
  206. get
  207. {
  208. if (_FFMpegDirectory == null)
  209. {
  210. _FFMpegDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.ProgramDataPath, "FFMpeg");
  211. if (!Directory.Exists(_FFMpegDirectory))
  212. {
  213. Directory.CreateDirectory(_FFMpegDirectory);
  214. }
  215. }
  216. return _FFMpegDirectory;
  217. }
  218. }
  219. private string _FFMpegPath;
  220. /// <summary>
  221. /// Gets the path to ffmpeg.exe
  222. /// </summary>
  223. public string FFMpegPath
  224. {
  225. get
  226. {
  227. if (_FFMpegPath == null)
  228. {
  229. _FFMpegPath = Path.Combine(FFMpegDirectory, "ffmpeg.exe");
  230. }
  231. return _FFMpegPath;
  232. }
  233. }
  234. private string _FFProbePath;
  235. /// <summary>
  236. /// Gets the path to ffprobe.exe
  237. /// </summary>
  238. public string FFProbePath
  239. {
  240. get
  241. {
  242. if (_FFProbePath == null)
  243. {
  244. _FFProbePath = Path.Combine(FFMpegDirectory, "ffprobe.exe");
  245. }
  246. return _FFProbePath;
  247. }
  248. }
  249. }
  250. }