IHasImages.cs 8.0 KB

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