ServerApplicationPaths.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using MediaBrowser.Common.Implementations;
  2. using MediaBrowser.Controller;
  3. using System;
  4. using System.IO;
  5. namespace MediaBrowser.Server.Implementations
  6. {
  7. /// <summary>
  8. /// Extends BaseApplicationPaths to add paths that are only applicable on the server
  9. /// </summary>
  10. public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
  11. {
  12. #if (DEBUG)
  13. /// <summary>
  14. /// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class.
  15. /// </summary>
  16. public ServerApplicationPaths(string applicationPath)
  17. : base(true, applicationPath)
  18. {
  19. }
  20. #else
  21. /// <summary>
  22. /// Initializes a new instance of the <see cref="ServerApplicationPaths"/> class.
  23. /// </summary>
  24. public ServerApplicationPaths(string applicationPath)
  25. : base(false, applicationPath)
  26. {
  27. }
  28. #endif
  29. /// <summary>
  30. /// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
  31. /// </summary>
  32. public ServerApplicationPaths(string programDataPath, string applicationPath)
  33. : base(programDataPath, applicationPath)
  34. {
  35. }
  36. /// <summary>
  37. /// Gets the path to the base root media directory
  38. /// </summary>
  39. /// <value>The root folder path.</value>
  40. public string RootFolderPath
  41. {
  42. get
  43. {
  44. return Path.Combine(ProgramDataPath, "root");
  45. }
  46. }
  47. /// <summary>
  48. /// Gets the path to the default user view directory. Used if no specific user view is defined.
  49. /// </summary>
  50. /// <value>The default user views path.</value>
  51. public string DefaultUserViewsPath
  52. {
  53. get
  54. {
  55. return Path.Combine(RootFolderPath, "default");
  56. }
  57. }
  58. /// <summary>
  59. /// Gets the path to localization data.
  60. /// </summary>
  61. /// <value>The localization path.</value>
  62. public string LocalizationPath
  63. {
  64. get
  65. {
  66. return Path.Combine(ProgramDataPath, "localization");
  67. }
  68. }
  69. /// <summary>
  70. /// The _ibn path
  71. /// </summary>
  72. private string _ibnPath;
  73. /// <summary>
  74. /// Gets the path to the Images By Name directory
  75. /// </summary>
  76. /// <value>The images by name path.</value>
  77. public string ItemsByNamePath
  78. {
  79. get
  80. {
  81. return _ibnPath ?? (_ibnPath = Path.Combine(ProgramDataPath, "ImagesByName"));
  82. }
  83. set
  84. {
  85. _ibnPath = value;
  86. }
  87. }
  88. /// <summary>
  89. /// Gets the path to the People directory
  90. /// </summary>
  91. /// <value>The people path.</value>
  92. public string PeoplePath
  93. {
  94. get
  95. {
  96. return Path.Combine(ItemsByNamePath, "People");
  97. }
  98. }
  99. /// <summary>
  100. /// Gets the path to the Genre directory
  101. /// </summary>
  102. /// <value>The genre path.</value>
  103. public string GenrePath
  104. {
  105. get
  106. {
  107. return Path.Combine(ItemsByNamePath, "Genre");
  108. }
  109. }
  110. /// <summary>
  111. /// Gets the path to the Genre directory
  112. /// </summary>
  113. /// <value>The genre path.</value>
  114. public string MusicGenrePath
  115. {
  116. get
  117. {
  118. return Path.Combine(ItemsByNamePath, "MusicGenre");
  119. }
  120. }
  121. /// <summary>
  122. /// Gets the path to the Studio directory
  123. /// </summary>
  124. /// <value>The studio path.</value>
  125. public string StudioPath
  126. {
  127. get
  128. {
  129. return Path.Combine(ItemsByNamePath, "Studio");
  130. }
  131. }
  132. /// <summary>
  133. /// Gets the path to the Year directory
  134. /// </summary>
  135. /// <value>The year path.</value>
  136. public string YearPath
  137. {
  138. get
  139. {
  140. return Path.Combine(ItemsByNamePath, "Year");
  141. }
  142. }
  143. /// <summary>
  144. /// Gets the path to the General IBN directory
  145. /// </summary>
  146. /// <value>The general path.</value>
  147. public string GeneralPath
  148. {
  149. get
  150. {
  151. return Path.Combine(ItemsByNamePath, "general");
  152. }
  153. }
  154. /// <summary>
  155. /// Gets the path to the Ratings IBN directory
  156. /// </summary>
  157. /// <value>The ratings path.</value>
  158. public string RatingsPath
  159. {
  160. get
  161. {
  162. return Path.Combine(ItemsByNamePath, "ratings");
  163. }
  164. }
  165. /// <summary>
  166. /// Gets the media info images path.
  167. /// </summary>
  168. /// <value>The media info images path.</value>
  169. public string MediaInfoImagesPath
  170. {
  171. get
  172. {
  173. return Path.Combine(ItemsByNamePath, "mediainfo");
  174. }
  175. }
  176. /// <summary>
  177. /// Gets the path to the user configuration directory
  178. /// </summary>
  179. /// <value>The user configuration directory path.</value>
  180. public string UserConfigurationDirectoryPath
  181. {
  182. get
  183. {
  184. return Path.Combine(ConfigurationDirectoryPath, "users");
  185. }
  186. }
  187. private string _transcodingTempPath;
  188. public string TranscodingTempPath
  189. {
  190. get
  191. {
  192. return _transcodingTempPath ?? (_transcodingTempPath = Path.Combine(ProgramDataPath, "transcoding-temp"));
  193. }
  194. set
  195. {
  196. _transcodingTempPath = value;
  197. }
  198. }
  199. /// <summary>
  200. /// Gets the artists path.
  201. /// </summary>
  202. /// <value>The artists path.</value>
  203. public string ArtistsPath
  204. {
  205. get
  206. {
  207. return Path.Combine(ItemsByNamePath, "artists");
  208. }
  209. }
  210. /// <summary>
  211. /// Gets the game genre path.
  212. /// </summary>
  213. /// <value>The game genre path.</value>
  214. public string GameGenrePath
  215. {
  216. get
  217. {
  218. return Path.Combine(ItemsByNamePath, "GameGenre");
  219. }
  220. }
  221. private string _internalMetadataPath;
  222. public string InternalMetadataPath
  223. {
  224. get
  225. {
  226. return _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
  227. }
  228. set
  229. {
  230. _internalMetadataPath = value;
  231. }
  232. }
  233. public string GetInternalMetadataPath(Guid id)
  234. {
  235. var idString = id.ToString("N");
  236. return Path.Combine(InternalMetadataPath, idString.Substring(0, 2), idString);
  237. }
  238. }
  239. }