parent
6741ca096b
commit
c8225db4fe
@ -1,4 +1,5 @@
|
|||||||
using System.IO.Compression;
|
using System.Globalization;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -66,8 +67,11 @@ public abstract class Connector
|
|||||||
{
|
{
|
||||||
Chapter[] newChapters = this.GetChapters(publication, language);
|
Chapter[] newChapters = this.GetChapters(publication, language);
|
||||||
collection.Add(publication);
|
collection.Add(publication);
|
||||||
|
NumberFormatInfo decimalPoint = new (){ NumberDecimalSeparator = "." };
|
||||||
logger?.WriteLine(this.GetType().ToString(), "Checking for duplicates");
|
logger?.WriteLine(this.GetType().ToString(), "Checking for duplicates");
|
||||||
List<Chapter> newChaptersList = newChapters.Where(nChapter => !nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList();
|
List<Chapter> newChaptersList = newChapters.Where(nChapter =>
|
||||||
|
float.Parse(nChapter.chapterNumber, decimalPoint) > publication.ignoreChaptersBelow &&
|
||||||
|
!nChapter.CheckChapterIsDownloaded(settings.downloadLocation)).ToList();
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"{newChaptersList.Count} new chapters.");
|
logger?.WriteLine(this.GetType().ToString(), $"{newChaptersList.Count} new chapters.");
|
||||||
|
|
||||||
return newChaptersList;
|
return newChaptersList;
|
||||||
|
@ -26,22 +26,11 @@ public readonly struct Publication
|
|||||||
public string folderName { get; }
|
public string folderName { get; }
|
||||||
public string publicationId { get; }
|
public string publicationId { get; }
|
||||||
public string internalId { get; }
|
public string internalId { get; }
|
||||||
|
public uint ignoreChaptersBelow { get; }
|
||||||
|
|
||||||
private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
|
private static readonly Regex LegalCharacters = new Regex(@"[A-Z]*[a-z]*[0-9]* *\.*-*,*'*\'*\)*\(*~*!*");
|
||||||
|
|
||||||
[JsonConstructor] //Legacy
|
public Publication(string sortName, List<string> authors, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId, string? folderName = null, uint ignoreChaptersBelow = 0)
|
||||||
public Publication(string sortName, string? author, string? description, Dictionary<string, string> altTitles,
|
|
||||||
string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string, string>? links, int? year,
|
|
||||||
string? originalLanguage, string status, string publicationId)
|
|
||||||
{
|
|
||||||
List<string> pAuthors = new();
|
|
||||||
if(author is not null)
|
|
||||||
pAuthors.Add(author);
|
|
||||||
this = new Publication(sortName, pAuthors, description, altTitles, tags, posterUrl,
|
|
||||||
coverFileNameInCache, links, year, originalLanguage, status, publicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Publication(string sortName, List<string> authors, string? description, Dictionary<string,string> altTitles, string[] tags, string? posterUrl, string? coverFileNameInCache, Dictionary<string,string>? links, int? year, string? originalLanguage, string status, string publicationId)
|
|
||||||
{
|
{
|
||||||
this.sortName = sortName;
|
this.sortName = sortName;
|
||||||
this.authors = authors;
|
this.authors = authors;
|
||||||
@ -55,11 +44,12 @@ public readonly struct Publication
|
|||||||
this.originalLanguage = originalLanguage;
|
this.originalLanguage = originalLanguage;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.publicationId = publicationId;
|
this.publicationId = publicationId;
|
||||||
this.folderName = string.Concat(LegalCharacters.Matches(sortName));
|
this.folderName = folderName ?? string.Concat(LegalCharacters.Matches(sortName));
|
||||||
while (this.folderName.EndsWith('.'))
|
while (this.folderName.EndsWith('.'))
|
||||||
this.folderName = this.folderName.Substring(0, this.folderName.Length - 1);
|
this.folderName = this.folderName.Substring(0, this.folderName.Length - 1);
|
||||||
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
||||||
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
||||||
|
this.ignoreChaptersBelow = ignoreChaptersBelow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CreatePublicationFolder(string downloadDirectory)
|
public string CreatePublicationFolder(string downloadDirectory)
|
||||||
|
Loading…
Reference in New Issue
Block a user