Video.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using MediaBrowser.Model.Entities;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Runtime.Serialization;
  6. namespace MediaBrowser.Controller.Entities
  7. {
  8. /// <summary>
  9. /// Class Video
  10. /// </summary>
  11. public class Video : BaseItem, IHasMediaStreams
  12. {
  13. /// <summary>
  14. /// Gets or sets the type of the video.
  15. /// </summary>
  16. /// <value>The type of the video.</value>
  17. public VideoType VideoType { get; set; }
  18. /// <summary>
  19. /// Gets or sets the type of the iso.
  20. /// </summary>
  21. /// <value>The type of the iso.</value>
  22. public IsoType? IsoType { get; set; }
  23. /// <summary>
  24. /// Gets or sets the format of the video.
  25. /// </summary>
  26. /// <value>The format of the video.</value>
  27. public VideoFormat VideoFormat { get; set; }
  28. /// <summary>
  29. /// Gets or sets the media streams.
  30. /// </summary>
  31. /// <value>The media streams.</value>
  32. public List<MediaStream> MediaStreams { get; set; }
  33. /// <summary>
  34. /// Gets or sets the chapters.
  35. /// </summary>
  36. /// <value>The chapters.</value>
  37. public List<ChapterInfo> Chapters { get; set; }
  38. /// <summary>
  39. /// If the video is a folder-rip, this will hold the file list for the largest playlist
  40. /// </summary>
  41. public List<string> PlayableStreamFileNames { get; set; }
  42. /// <summary>
  43. /// Gets the playable stream files.
  44. /// </summary>
  45. /// <returns>List{System.String}.</returns>
  46. public List<string> GetPlayableStreamFiles()
  47. {
  48. return GetPlayableStreamFiles(Path);
  49. }
  50. /// <summary>
  51. /// Gets the playable stream files.
  52. /// </summary>
  53. /// <param name="rootPath">The root path.</param>
  54. /// <returns>List{System.String}.</returns>
  55. public List<string> GetPlayableStreamFiles(string rootPath)
  56. {
  57. if (PlayableStreamFileNames == null)
  58. {
  59. return null;
  60. }
  61. var allFiles = Directory.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories).ToList();
  62. return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, System.StringComparison.OrdinalIgnoreCase)))
  63. .Where(f => !string.IsNullOrEmpty(f))
  64. .ToList();
  65. }
  66. /// <summary>
  67. /// The default video stream for this video. Use this to determine media info for this item.
  68. /// </summary>
  69. /// <value>The default video stream.</value>
  70. [IgnoreDataMember]
  71. public MediaStream DefaultVideoStream
  72. {
  73. get { return MediaStreams != null ? MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video) : null; }
  74. }
  75. /// <summary>
  76. /// Gets a value indicating whether [is3 D].
  77. /// </summary>
  78. /// <value><c>true</c> if [is3 D]; otherwise, <c>false</c>.</value>
  79. [IgnoreDataMember]
  80. public bool Is3D
  81. {
  82. get { return VideoFormat > 0; }
  83. }
  84. /// <summary>
  85. /// Gets the type of the media.
  86. /// </summary>
  87. /// <value>The type of the media.</value>
  88. public override string MediaType
  89. {
  90. get
  91. {
  92. return Model.Entities.MediaType.Video;
  93. }
  94. }
  95. }
  96. }