Added Series Info Capability
This commit is contained in:
parent
a54b5e9e1f
commit
e8f25ca9d0
@ -31,7 +31,10 @@ public static class Tranga_Cli
|
|||||||
Chapter[] downloadChapters = SelectChapters(allChapteres);
|
Chapter[] downloadChapters = SelectChapters(allChapteres);
|
||||||
|
|
||||||
if (downloadChapters.Length > 0)
|
if (downloadChapters.Length > 0)
|
||||||
|
{
|
||||||
connector.DownloadCover(selectedPub);
|
connector.DownloadCover(selectedPub);
|
||||||
|
File.WriteAllText(Path.Join(folderPath, selectedPub.folderName, "series.json"),selectedPub.GetSeriesInfo());
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Chapter chapter in downloadChapters)
|
foreach (Chapter chapter in downloadChapters)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
namespace Tranga;
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Tranga;
|
||||||
|
|
||||||
public struct Publication
|
public struct Publication
|
||||||
{
|
{
|
||||||
@ -30,4 +33,33 @@ public struct Publication
|
|||||||
this.downloadUrl = downloadUrl;
|
this.downloadUrl = downloadUrl;
|
||||||
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars()));
|
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetSeriesInfo()
|
||||||
|
{
|
||||||
|
SeriesInfo si = new (new Metadata(this.sortName, this.year.ToString() ?? string.Empty, this.status, this.description ?? ""));
|
||||||
|
return JsonSerializer.Serialize(si, JsonSerializerOptions.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct SeriesInfo
|
||||||
|
{
|
||||||
|
[JsonInclude]public Metadata metadata { get; }
|
||||||
|
public SeriesInfo(Metadata metadata) => this.metadata = metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal struct Metadata
|
||||||
|
{
|
||||||
|
[JsonInclude]public string name { get; }
|
||||||
|
[JsonInclude]public string year { get; }
|
||||||
|
[JsonInclude]public string status { get; }
|
||||||
|
// ReSharper disable twice InconsistentNaming
|
||||||
|
[JsonInclude]public string description_text { get; }
|
||||||
|
|
||||||
|
public Metadata(string name, string year, string status, string description_text)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.year = year;
|
||||||
|
this.status = status;
|
||||||
|
this.description_text = description_text;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user