Compare commits

..

No commits in common. "d6a62dc3155433e73882be12d3e99b93a1bf1c52" and "496d502cd2ab143d428cbc937c7b9d1d576a9207" have entirely different histories.

4 changed files with 7 additions and 25 deletions

View File

@ -20,20 +20,16 @@ public struct Chapter
public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url) public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url)
{ {
this.name = name; this.name = name;
this.volumeNumber = volumeNumber; this.volumeNumber = volumeNumber is { Length: > 0 } ? volumeNumber : "1";
this.chapterNumber = chapterNumber; this.chapterNumber = chapterNumber;
this.url = url; this.url = url;
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
NumberFormatInfo nfi = new NumberFormatInfo() NumberFormatInfo nfi = new NumberFormatInfo()
{ {
NumberDecimalSeparator = "." NumberDecimalSeparator = "."
}; };
sortNumber = decimal.Round(Convert.ToDecimal(this.volumeNumber) * Convert.ToDecimal(this.chapterNumber, nfi), 1) sortNumber = decimal.Round(Convert.ToDecimal(this.volumeNumber) * Convert.ToDecimal(this.chapterNumber, nfi), 1)
.ToString(nfi); .ToString(nfi);
this.fileName = $"{chapterName} - V{volumeNumber}C{chapterNumber} - {sortNumber}";
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
string volStr = this.volumeNumber is not null ? $"Vol.{this.volumeNumber} " : "";
string chNumberStr = this.chapterNumber is not null ? $"Ch.{chapterNumber} " : "";
string chNameStr = chapterName.Length > 0 ? $"- {chapterName}" : "";
this.fileName = $"{volStr}{chNumberStr}{chNameStr}";
} }
} }

View File

@ -1,7 +1,6 @@
using System.IO.Compression; using System.IO.Compression;
using System.Net; using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Xml.Linq; using System.Xml.Linq;
using Logging; using Logging;
using static System.IO.UnixFileMode; using static System.IO.UnixFileMode;
@ -112,20 +111,7 @@ public abstract class Connector
/// <returns>true if chapter is present</returns> /// <returns>true if chapter is present</returns>
public bool CheckChapterIsDownloaded(Publication publication, Chapter chapter) public bool CheckChapterIsDownloaded(Publication publication, Chapter chapter)
{ {
Regex legalCharacters = new Regex(@"([A-z]*[0-9]* *\.*-*,*\]*\[*'*\'*\)*\(*~*!*)*"); return File.Exists(GetArchiveFilePath(publication, chapter));
string oldFilePath = Path.Join(downloadLocation, publication.folderName, $"{string.Concat(legalCharacters.Matches(chapter.name ?? ""))} - V{chapter.volumeNumber}C{chapter.chapterNumber} - {chapter.sortNumber}.cbz");
string oldFilePath2 = Path.Join(downloadLocation, publication.folderName, $"{string.Concat(legalCharacters.Matches(chapter.name ?? ""))} - VC{chapter.chapterNumber} - {chapter.sortNumber}.cbz");
string newFilePath = GetArchiveFilePath(publication, chapter);
if (File.Exists(oldFilePath))
{
logger?.WriteLine(this.GetType().ToString(), $"Moving old file {oldFilePath} -> {newFilePath}");
File.Move(oldFilePath, newFilePath);
}else if (File.Exists(oldFilePath2))
{
logger?.WriteLine(this.GetType().ToString(), $"Moving old file {oldFilePath2} -> {newFilePath}");
File.Move(oldFilePath2, newFilePath);
}
return File.Exists(newFilePath);
} }
/// <summary> /// <summary>
@ -134,7 +120,7 @@ public abstract class Connector
/// <returns>Filepath</returns> /// <returns>Filepath</returns>
protected string GetArchiveFilePath(Publication publication, Chapter chapter) protected string GetArchiveFilePath(Publication publication, Chapter chapter)
{ {
return Path.Join(downloadLocation, publication.folderName, $"{publication.folderName} - {chapter.fileName}.cbz"); return Path.Join(downloadLocation, publication.folderName, $"{chapter.fileName}.cbz");
} }
/// <summary> /// <summary>

View File

@ -157,7 +157,7 @@ public class Manganato : Connector
.GetAttributeValue("href", ""); .GetAttributeValue("href", "");
ret.Add(new Chapter(chapterName, volumeNumber, chapterNumber, url)); ret.Add(new Chapter(chapterName, volumeNumber, chapterNumber, url));
} }
ret.Reverse();
return ret.ToArray(); return ret.ToArray();
} }

View File

@ -289,7 +289,7 @@ function UpdateLibrarySettings(){
UpdateSettings("", "", "", settingKavitaUrl.value, settingKavitaUser.value, settingKavitaPass.value); UpdateSettings("", "", "", settingKavitaUrl.value, settingKavitaUser.value, settingKavitaPass.value);
} }
CreateTask("UpdateLibraries", libraryUpdateTime.value, "","",""); CreateTask("UpdateLibraries", libraryUpdateTime.value, "","","");
setTimeout(() => GetSettingsClick(), 200); setTimeout(() => GetSettingsClick(), 100);
} }
function utf8_to_b64( str ) { function utf8_to_b64( str ) {