2018-09-12 10:26:21 -07:00
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Emby.Naming.AudioBook
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-03-25 13:31:03 -07:00
|
|
|
/// Represents a single video file.
|
2018-09-12 10:26:21 -07:00
|
|
|
/// </summary>
|
|
|
|
public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
|
|
|
|
{
|
2020-11-01 02:47:31 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="AudioBookFileInfo"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="path">Path to audiobook file.</param>
|
|
|
|
/// <param name="container">File type.</param>
|
|
|
|
/// <param name="partNumber">Number of part this file represents.</param>
|
|
|
|
/// <param name="chapterNumber">Number of chapter this file represents.</param>
|
2020-11-01 05:42:56 -07:00
|
|
|
public AudioBookFileInfo(string path, string container, int? partNumber = default, int? chapterNumber = default)
|
2020-11-01 02:47:31 -07:00
|
|
|
{
|
|
|
|
Path = path;
|
|
|
|
Container = container;
|
|
|
|
PartNumber = partNumber;
|
|
|
|
ChapterNumber = chapterNumber;
|
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
/// <summary>
|
2020-03-25 13:31:03 -07:00
|
|
|
/// Gets or sets the path.
|
2018-09-12 10:26:21 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The path.</value>
|
|
|
|
public string Path { get; set; }
|
2019-05-10 11:37:42 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
/// <summary>
|
2020-03-25 13:31:03 -07:00
|
|
|
/// Gets or sets the container.
|
2018-09-12 10:26:21 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The container.</value>
|
|
|
|
public string Container { get; set; }
|
2019-05-10 11:37:42 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
/// <summary>
|
2020-03-25 13:31:03 -07:00
|
|
|
/// Gets or sets the part number.
|
2018-09-12 10:26:21 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The part number.</value>
|
|
|
|
public int? PartNumber { get; set; }
|
2019-05-10 11:37:42 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
/// <summary>
|
2020-03-25 13:31:03 -07:00
|
|
|
/// Gets or sets the chapter number.
|
2018-09-12 10:26:21 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The chapter number.</value>
|
|
|
|
public int? ChapterNumber { get; set; }
|
2019-05-10 11:37:42 -07:00
|
|
|
|
2020-03-25 09:53:03 -07:00
|
|
|
/// <inheritdoc />
|
2020-11-01 02:47:31 -07:00
|
|
|
public int CompareTo(AudioBookFileInfo? other)
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
2019-05-10 11:37:42 -07:00
|
|
|
if (ReferenceEquals(this, other))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
var chapterNumberComparison = Nullable.Compare(ChapterNumber, other.ChapterNumber);
|
2019-05-10 11:37:42 -07:00
|
|
|
if (chapterNumberComparison != 0)
|
|
|
|
{
|
|
|
|
return chapterNumberComparison;
|
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
var partNumberComparison = Nullable.Compare(PartNumber, other.PartNumber);
|
2019-05-10 11:37:42 -07:00
|
|
|
if (partNumberComparison != 0)
|
|
|
|
{
|
|
|
|
return partNumberComparison;
|
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
return string.Compare(Path, other.Path, StringComparison.Ordinal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|