#74 untested
This commit is contained in:
parent
438c11af4f
commit
d78897eb74
@ -14,7 +14,7 @@ public abstract class GlobalBase
|
||||
protected HashSet<NotificationConnector> notificationConnectors { get; init; }
|
||||
protected HashSet<LibraryConnector> libraryConnectors { get; init; }
|
||||
protected List<Manga> cachedPublications { get; init; }
|
||||
protected static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." };
|
||||
public static readonly NumberFormatInfo numberFormatDecimalPoint = new (){ NumberDecimalSeparator = "." };
|
||||
protected static readonly Regex baseUrlRex = new(@"https?:\/\/[0-9A-z\.-]*");
|
||||
|
||||
protected GlobalBase(GlobalBase clone)
|
||||
|
@ -33,6 +33,7 @@ public class DownloadChapter : Job
|
||||
{
|
||||
mangaConnector.CopyCoverFromCacheToDownloadLocation(chapter.parentManga);
|
||||
HttpStatusCode success = mangaConnector.DownloadChapter(chapter, this.progressToken);
|
||||
chapter.parentManga.UpdateLatestDownloadedChapter(chapter);
|
||||
if (success == HttpStatusCode.OK)
|
||||
{
|
||||
UpdateLibraries();
|
||||
|
@ -26,12 +26,14 @@ public struct Manga
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
public int? year { get; }
|
||||
public string? originalLanguage { get; }
|
||||
// ReSharper disable once MemberCanBePrivate.Global
|
||||
// ReSharper disable twice MemberCanBePrivate.Global
|
||||
public string status { get; }
|
||||
public string folderName { get; private set; }
|
||||
public string publicationId { get; }
|
||||
public string internalId { get; }
|
||||
public float ignoreChaptersBelow { get; set; }
|
||||
public float latestChapterDownloaded { get; set; }
|
||||
public float latestChapterAvailable { get; set; }
|
||||
|
||||
private static readonly Regex LegalCharacters = new (@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
|
||||
|
||||
@ -56,6 +58,8 @@ public struct Manga
|
||||
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
||||
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
||||
this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
|
||||
this.latestChapterDownloaded = 0;
|
||||
this.latestChapterAvailable = 0;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -82,6 +86,12 @@ public struct Manga
|
||||
Directory.Move(oldPath, newPath);
|
||||
}
|
||||
|
||||
public void UpdateLatestDownloadedChapter(Chapter chapter)//TODO check files if chapters are all downloaded
|
||||
{
|
||||
float chapterNumber = Convert.ToSingle(chapter.chapterNumber, GlobalBase.numberFormatDecimalPoint);
|
||||
latestChapterDownloaded = latestChapterDownloaded < chapterNumber ? chapterNumber : latestChapterDownloaded;
|
||||
}
|
||||
|
||||
public void SaveSeriesInfoJson(string downloadDirectory)
|
||||
{
|
||||
string publicationFolder = CreatePublicationFolder(downloadDirectory);
|
||||
|
@ -56,12 +56,15 @@ public abstract class MangaConnector : GlobalBase
|
||||
public Chapter[] GetNewChapters(Manga manga, string language = "en")
|
||||
{
|
||||
Log($"Getting new Chapters for {manga}");
|
||||
Chapter[] newChapters = this.GetChapters(manga, language);
|
||||
Chapter[] allChapters = this.GetChapters(manga, language);
|
||||
Log($"Checking for duplicates {manga}");
|
||||
List<Chapter> newChaptersList = newChapters.Where(nChapter => float.TryParse(nChapter.chapterNumber, numberFormatDecimalPoint, out float chapterNumber)
|
||||
List<Chapter> newChaptersList = allChapters.Where(nChapter => float.TryParse(nChapter.chapterNumber, numberFormatDecimalPoint, out float chapterNumber)
|
||||
&& chapterNumber > manga.ignoreChaptersBelow
|
||||
&& !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList();
|
||||
Log($"{newChaptersList.Count} new chapters. {manga}");
|
||||
Chapter latestChapterAvailable =
|
||||
allChapters.MaxBy(chapter => Convert.ToSingle(chapter.chapterNumber, numberFormatDecimalPoint));
|
||||
manga.latestChapterAvailable = Convert.ToSingle(latestChapterAvailable.chapterNumber, numberFormatDecimalPoint);
|
||||
|
||||
return newChaptersList.ToArray();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user