2023-05-18 20:06:29 +02:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace Tranga;
|
2023-05-17 23:23:01 +02:00
|
|
|
|
|
|
|
|
|
public struct Chapter
|
|
|
|
|
{
|
|
|
|
|
public Publication publication { get; }
|
2023-05-18 16:03:00 +02:00
|
|
|
|
public string? name { get; }
|
|
|
|
|
public string? volumeNumber { get; }
|
|
|
|
|
public string? chapterNumber { get; }
|
2023-05-18 16:21:21 +02:00
|
|
|
|
public string url { get; }
|
2023-05-18 18:42:36 +02:00
|
|
|
|
|
2023-05-18 19:51:26 +02:00
|
|
|
|
public string fileName { get; }
|
2023-05-17 23:23:01 +02:00
|
|
|
|
|
2023-05-18 20:06:29 +02:00
|
|
|
|
public Chapter(Publication publication, string? name, string? volumeNumber, string? chapterNumber, string url)
|
2023-05-17 23:23:01 +02:00
|
|
|
|
{
|
|
|
|
|
this.publication = publication;
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.volumeNumber = volumeNumber;
|
|
|
|
|
this.chapterNumber = chapterNumber;
|
2023-05-18 16:21:21 +02:00
|
|
|
|
this.url = url;
|
2023-05-18 20:06:29 +02:00
|
|
|
|
string chapterName = string.Concat((name ?? "").Split(Path.GetInvalidFileNameChars()));
|
2023-05-18 20:07:47 +02:00
|
|
|
|
double multiplied = Convert.ToDouble(chapterNumber, new NumberFormatInfo() { NumberDecimalSeparator = "." }) *
|
2023-05-18 20:06:29 +02:00
|
|
|
|
Convert.ToInt32(volumeNumber);
|
|
|
|
|
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {multiplied}";
|
2023-05-17 23:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|