Moved filenaming to Chapter struct
This commit is contained in:
parent
c283cbd9a9
commit
f5225f9f29
@ -1,4 +1,6 @@
|
||||
namespace Tranga;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Tranga;
|
||||
|
||||
public struct Chapter
|
||||
{
|
||||
@ -10,13 +12,16 @@ public struct Chapter
|
||||
|
||||
public string fileName { get; }
|
||||
|
||||
public Chapter(Publication publication, string? name, string? volumeNumber, string? chapterNumber, string url, string fileName)
|
||||
public Chapter(Publication publication, string? name, string? volumeNumber, string? chapterNumber, string url)
|
||||
{
|
||||
this.publication = publication;
|
||||
this.name = name;
|
||||
this.volumeNumber = volumeNumber;
|
||||
this.chapterNumber = chapterNumber;
|
||||
this.url = url;
|
||||
this.fileName = fileName;
|
||||
string chapterName = string.Concat((name ?? "").Split(Path.GetInvalidFileNameChars()));
|
||||
double multiplied = Convert.ToDouble(chapterName, new NumberFormatInfo() { NumberDecimalSeparator = "." }) *
|
||||
Convert.ToInt32(volumeNumber);
|
||||
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {multiplied}";
|
||||
}
|
||||
}
|
@ -149,10 +149,7 @@ public class MangaDex : Connector
|
||||
? attributes["chapter"]!.GetValue<string>()
|
||||
: null;
|
||||
|
||||
string chapterName = string.Concat((title ?? "").Split(Path.GetInvalidFileNameChars()));
|
||||
string chapterFileName = $"{chapterName} - V{volume}C{chapterNum}";
|
||||
|
||||
chapters.Add(new Chapter(publication, title, volume, chapterNum, chapterId, chapterFileName));
|
||||
chapters.Add(new Chapter(publication, title, volume, chapterNum, chapterId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +188,7 @@ public class MangaDex : Connector
|
||||
|
||||
public override void DownloadCover(Publication publication)
|
||||
{
|
||||
DownloadClient.RequestResult requestResult = _downloadClient.MakeRequest($"https://uploads.mangadex.org/cover/{publication.posterUrl}");
|
||||
DownloadClient.RequestResult requestResult = _downloadClient.MakeRequest($"https://api.mangadex.org/cover/{publication.posterUrl}");
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(requestResult.result);
|
||||
if (result is null)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user