VideoFileInfo.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using MediaBrowser.Model.Entities;
  3. namespace Emby.Naming.Video
  4. {
  5. /// <summary>
  6. /// Represents a single video file.
  7. /// </summary>
  8. public class VideoFileInfo
  9. {
  10. /// <summary>
  11. /// Initializes a new instance of the <see cref="VideoFileInfo"/> class.
  12. /// </summary>
  13. /// <param name="name">Name of file.</param>
  14. /// <param name="path">Path to the file.</param>
  15. /// <param name="container">Container type.</param>
  16. /// <param name="year">Year of release.</param>
  17. /// <param name="extraType">Extra type.</param>
  18. /// <param name="extraRule">Extra rule.</param>
  19. /// <param name="format3D">Format 3D.</param>
  20. /// <param name="is3D">Is 3D.</param>
  21. /// <param name="isStub">Is Stub.</param>
  22. /// <param name="stubType">Stub type.</param>
  23. /// <param name="isDirectory">Is directory.</param>
  24. public VideoFileInfo(string name, string path, string? container, int? year = default, ExtraType? extraType = default, ExtraRule? extraRule = default, string? format3D = default, bool is3D = default, bool isStub = default, string? stubType = default, bool isDirectory = default)
  25. {
  26. Path = path;
  27. Container = container;
  28. Name = name;
  29. Year = year;
  30. ExtraType = extraType;
  31. ExtraRule = extraRule;
  32. Format3D = format3D;
  33. Is3D = is3D;
  34. IsStub = isStub;
  35. StubType = stubType;
  36. IsDirectory = isDirectory;
  37. }
  38. /// <summary>
  39. /// Gets or sets the path.
  40. /// </summary>
  41. /// <value>The path.</value>
  42. public string Path { get; set; }
  43. /// <summary>
  44. /// Gets or sets the container.
  45. /// </summary>
  46. /// <value>The container.</value>
  47. public string? Container { get; set; }
  48. /// <summary>
  49. /// Gets or sets the name.
  50. /// </summary>
  51. /// <value>The name.</value>
  52. public string Name { get; set; }
  53. /// <summary>
  54. /// Gets or sets the year.
  55. /// </summary>
  56. /// <value>The year.</value>
  57. public int? Year { get; set; }
  58. /// <summary>
  59. /// Gets or sets the type of the extra, e.g. trailer, theme song, behind the scenes, etc.
  60. /// </summary>
  61. /// <value>The type of the extra.</value>
  62. public ExtraType? ExtraType { get; set; }
  63. /// <summary>
  64. /// Gets or sets the extra rule.
  65. /// </summary>
  66. /// <value>The extra rule.</value>
  67. public ExtraRule? ExtraRule { get; set; }
  68. /// <summary>
  69. /// Gets or sets the format3 d.
  70. /// </summary>
  71. /// <value>The format3 d.</value>
  72. public string? Format3D { get; set; }
  73. /// <summary>
  74. /// Gets or sets a value indicating whether [is3 d].
  75. /// </summary>
  76. /// <value><c>true</c> if [is3 d]; otherwise, <c>false</c>.</value>
  77. public bool Is3D { get; set; }
  78. /// <summary>
  79. /// Gets or sets a value indicating whether this instance is stub.
  80. /// </summary>
  81. /// <value><c>true</c> if this instance is stub; otherwise, <c>false</c>.</value>
  82. public bool IsStub { get; set; }
  83. /// <summary>
  84. /// Gets or sets the type of the stub.
  85. /// </summary>
  86. /// <value>The type of the stub.</value>
  87. public string? StubType { get; set; }
  88. /// <summary>
  89. /// Gets or sets a value indicating whether this instance is a directory.
  90. /// </summary>
  91. /// <value>The type.</value>
  92. public bool IsDirectory { get; set; }
  93. /// <summary>
  94. /// Gets the file name without extension.
  95. /// </summary>
  96. /// <value>The file name without extension.</value>
  97. public ReadOnlySpan<char> FileNameWithoutExtension => !IsDirectory
  98. ? System.IO.Path.GetFileNameWithoutExtension(Path.AsSpan())
  99. : System.IO.Path.GetFileName(Path.AsSpan());
  100. /// <inheritdoc />
  101. public override string ToString()
  102. {
  103. return "VideoFileInfo(Name: '" + Name + "')";
  104. }
  105. }
  106. }