ServerApplicationPaths.cs 8.2 KB

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