IHasImages.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Entities;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Controller.Entities
  7. {
  8. public interface IHasImages : IHasProviderIds, IHasId
  9. {
  10. /// <summary>
  11. /// Gets the name.
  12. /// </summary>
  13. /// <value>The name.</value>
  14. string Name { get; set; }
  15. /// <summary>
  16. /// Gets the path.
  17. /// </summary>
  18. /// <value>The path.</value>
  19. string Path { get; set; }
  20. /// <summary>
  21. /// Gets the file name without extension.
  22. /// </summary>
  23. /// <value>The file name without extension.</value>
  24. string FileNameWithoutExtension { get; }
  25. /// <summary>
  26. /// Gets the type of the location.
  27. /// </summary>
  28. /// <value>The type of the location.</value>
  29. LocationType LocationType { get; }
  30. /// <summary>
  31. /// Gets the locked fields.
  32. /// </summary>
  33. /// <value>The locked fields.</value>
  34. List<MetadataFields> LockedFields { get; }
  35. /// <summary>
  36. /// Gets the images.
  37. /// </summary>
  38. /// <param name="imageType">Type of the image.</param>
  39. /// <returns>IEnumerable{ItemImageInfo}.</returns>
  40. IEnumerable<ItemImageInfo> GetImages(ImageType imageType);
  41. /// <summary>
  42. /// Gets the image path.
  43. /// </summary>
  44. /// <param name="imageType">Type of the image.</param>
  45. /// <param name="imageIndex">Index of the image.</param>
  46. /// <returns>System.String.</returns>
  47. string GetImagePath(ImageType imageType, int imageIndex);
  48. /// <summary>
  49. /// Gets the image information.
  50. /// </summary>
  51. /// <param name="imageType">Type of the image.</param>
  52. /// <param name="imageIndex">Index of the image.</param>
  53. /// <returns>ItemImageInfo.</returns>
  54. ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex);
  55. /// <summary>
  56. /// Sets the image.
  57. /// </summary>
  58. /// <param name="type">The type.</param>
  59. /// <param name="index">The index.</param>
  60. /// <param name="file">The file.</param>
  61. void SetImagePath(ImageType type, int index, FileSystemInfo file);
  62. /// <summary>
  63. /// Determines whether the specified type has image.
  64. /// </summary>
  65. /// <param name="type">The type.</param>
  66. /// <param name="imageIndex">Index of the image.</param>
  67. /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
  68. bool HasImage(ImageType type, int imageIndex);
  69. /// <summary>
  70. /// Allowses the multiple images.
  71. /// </summary>
  72. /// <param name="type">The type.</param>
  73. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  74. bool AllowsMultipleImages(ImageType type);
  75. /// <summary>
  76. /// Swaps the images.
  77. /// </summary>
  78. /// <param name="type">The type.</param>
  79. /// <param name="index1">The index1.</param>
  80. /// <param name="index2">The index2.</param>
  81. /// <returns>Task.</returns>
  82. Task SwapImages(ImageType type, int index1, int index2);
  83. /// <summary>
  84. /// Gets the display type of the media.
  85. /// </summary>
  86. /// <value>The display type of the media.</value>
  87. string DisplayMediaType { get; set; }
  88. /// <summary>
  89. /// Gets or sets the primary image path.
  90. /// </summary>
  91. /// <value>The primary image path.</value>
  92. string PrimaryImagePath { get; }
  93. /// <summary>
  94. /// Gets the preferred metadata language.
  95. /// </summary>
  96. /// <returns>System.String.</returns>
  97. string GetPreferredMetadataLanguage();
  98. /// <summary>
  99. /// Validates the images and returns true or false indicating if any were removed.
  100. /// </summary>
  101. bool ValidateImages(IDirectoryService directoryService);
  102. /// <summary>
  103. /// Gets a value indicating whether this instance is owned item.
  104. /// </summary>
  105. /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value>
  106. bool IsOwnedItem { get; }
  107. /// <summary>
  108. /// Gets the containing folder path.
  109. /// </summary>
  110. /// <value>The containing folder path.</value>
  111. string ContainingFolderPath { get; }
  112. /// <summary>
  113. /// Adds the images.
  114. /// </summary>
  115. /// <param name="imageType">Type of the image.</param>
  116. /// <param name="images">The images.</param>
  117. /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
  118. bool AddImages(ImageType imageType, List<FileSystemInfo> images);
  119. /// <summary>
  120. /// Determines whether [is save local metadata enabled].
  121. /// </summary>
  122. /// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns>
  123. bool IsSaveLocalMetadataEnabled();
  124. /// <summary>
  125. /// Gets a value indicating whether [supports local metadata].
  126. /// </summary>
  127. /// <value><c>true</c> if [supports local metadata]; otherwise, <c>false</c>.</value>
  128. bool SupportsLocalMetadata { get; }
  129. /// <summary>
  130. /// Gets a value indicating whether this instance is in mixed folder.
  131. /// </summary>
  132. /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
  133. bool IsInMixedFolder { get; }
  134. /// <summary>
  135. /// Gets a value indicating whether this instance is locked.
  136. /// </summary>
  137. /// <value><c>true</c> if this instance is locked; otherwise, <c>false</c>.</value>
  138. bool IsLocked { get; }
  139. /// <summary>
  140. /// Gets a value indicating whether [supports remote image downloading].
  141. /// </summary>
  142. /// <value><c>true</c> if [supports remote image downloading]; otherwise, <c>false</c>.</value>
  143. bool SupportsRemoteImageDownloading { get; }
  144. /// <summary>
  145. /// Gets the internal metadata path.
  146. /// </summary>
  147. /// <returns>System.String.</returns>
  148. string GetInternalMetadataPath();
  149. /// <summary>
  150. /// Gets a value indicating whether [always scan internal metadata path].
  151. /// </summary>
  152. /// <value><c>true</c> if [always scan internal metadata path]; otherwise, <c>false</c>.</value>
  153. bool AlwaysScanInternalMetadataPath { get; }
  154. /// <summary>
  155. /// Determines whether [is internet metadata enabled].
  156. /// </summary>
  157. /// <returns><c>true</c> if [is internet metadata enabled]; otherwise, <c>false</c>.</returns>
  158. bool IsInternetMetadataEnabled();
  159. /// <summary>
  160. /// Removes the image.
  161. /// </summary>
  162. /// <param name="image">The image.</param>
  163. void RemoveImage(ItemImageInfo image);
  164. }
  165. public static class HasImagesExtensions
  166. {
  167. /// <summary>
  168. /// Gets the image path.
  169. /// </summary>
  170. /// <param name="item">The item.</param>
  171. /// <param name="imageType">Type of the image.</param>
  172. /// <returns>System.String.</returns>
  173. public static string GetImagePath(this IHasImages item, ImageType imageType)
  174. {
  175. return item.GetImagePath(imageType, 0);
  176. }
  177. public static bool HasImage(this IHasImages item, ImageType imageType)
  178. {
  179. return item.HasImage(imageType, 0);
  180. }
  181. /// <summary>
  182. /// Sets the image path.
  183. /// </summary>
  184. /// <param name="item">The item.</param>
  185. /// <param name="imageType">Type of the image.</param>
  186. /// <param name="file">The file.</param>
  187. public static void SetImagePath(this IHasImages item, ImageType imageType, FileSystemInfo file)
  188. {
  189. item.SetImagePath(imageType, 0, file);
  190. }
  191. /// <summary>
  192. /// Sets the image path.
  193. /// </summary>
  194. /// <param name="item">The item.</param>
  195. /// <param name="imageType">Type of the image.</param>
  196. /// <param name="file">The file.</param>
  197. public static void SetImagePath(this IHasImages item, ImageType imageType, string file)
  198. {
  199. item.SetImagePath(imageType, new FileInfo(file));
  200. }
  201. }
  202. }