Compare commits
3 Commits
d8df6eccb1
...
2f0fbbd3cb
Author | SHA1 | Date | |
---|---|---|---|
2f0fbbd3cb | |||
5bc414fd59 | |||
2eaeadb92c |
@ -27,13 +27,20 @@ public readonly struct Chapter : IComparable
|
|||||||
this.volumeNumber = volumeNumber ?? "0";
|
this.volumeNumber = volumeNumber ?? "0";
|
||||||
this.chapterNumber = chapterNumber;
|
this.chapterNumber = chapterNumber;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
|
||||||
|
string chapterVolNumStr;
|
||||||
|
if (volumeNumber is not null && volumeNumber.Length > 0)
|
||||||
|
chapterVolNumStr = $"Vol.{volumeNumber} Ch.{chapterNumber}";
|
||||||
|
else
|
||||||
|
chapterVolNumStr = $"Ch.{chapterNumber}";
|
||||||
|
|
||||||
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
|
if (name is not null && name.Length > 0)
|
||||||
string volStr = volumeNumber is not null ? $"Vol.{volumeNumber} " : "";
|
{
|
||||||
string chNumberStr = $"Ch.{chapterNumber} ";
|
string chapterName = IllegalStrings.Replace(string.Concat(LegalCharacters.Matches(name)), "");
|
||||||
string chNameStr = chapterName.Length > 0 ? $"- {chapterName}" : "";
|
this.fileName = $"{chapterVolNumStr} - {chapterName}";
|
||||||
chNameStr = IllegalStrings.Replace(chNameStr, "");
|
}
|
||||||
this.fileName = $"{volStr}{chNumberStr}{chNameStr}";
|
else
|
||||||
|
this.fileName = chapterVolNumStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -81,23 +88,20 @@ public readonly struct Chapter : IComparable
|
|||||||
/// <returns>true if chapter is present</returns>
|
/// <returns>true if chapter is present</returns>
|
||||||
internal bool CheckChapterIsDownloaded(string downloadLocation)
|
internal bool CheckChapterIsDownloaded(string downloadLocation)
|
||||||
{
|
{
|
||||||
string newFilePath = GetArchiveFilePath(downloadLocation);
|
|
||||||
if (!Directory.Exists(Path.Join(downloadLocation, parentManga.folderName)))
|
if (!Directory.Exists(Path.Join(downloadLocation, parentManga.folderName)))
|
||||||
return false;
|
return false;
|
||||||
FileInfo[] archives = new DirectoryInfo(Path.Join(downloadLocation, parentManga.folderName)).GetFiles();
|
FileInfo[] archives = new DirectoryInfo(Path.Join(downloadLocation, parentManga.folderName)).GetFiles();
|
||||||
Regex chapterInfoRex = new(@"Ch\.[0-9.]+");
|
Regex volChRex = new(@".*Vol(?:ume)?\.?([0-9]+).*Ch(?:apter)?\.?([0-9]+[\.0-9]*).*");
|
||||||
Regex chapterRex = new(@"[0-9]+(\.[0-9]+)?");
|
|
||||||
|
|
||||||
if (File.Exists(newFilePath))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
string cn = this.chapterNumber;
|
Chapter t = this;
|
||||||
if (archives.FirstOrDefault(archive => chapterRex.Match(chapterInfoRex.Match(archive.Name).Value).Value == cn) is { } path)
|
return archives.Select(archive => archive.Name).Any(archiveFileName =>
|
||||||
{
|
{
|
||||||
File.Move(path.FullName, newFilePath);
|
Match m = volChRex.Match(archiveFileName);
|
||||||
return true;
|
string archiveVolNum = m.Groups[1].Value;
|
||||||
}
|
string archiveChNum = m.Groups[2].Value;
|
||||||
return false;
|
return archiveVolNum == t.volumeNumber &&
|
||||||
|
archiveChNum == t.chapterNumber;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates full file path of chapter-archive
|
/// Creates full file path of chapter-archive
|
||||||
|
Loading…
Reference in New Issue
Block a user