diff --git a/Tranga/Connector.cs b/Tranga/Connector.cs
index 0ff35ed..c2339ea 100644
--- a/Tranga/Connector.cs
+++ b/Tranga/Connector.cs
@@ -87,7 +87,7 @@ public abstract class Connector
/// XML-string
protected static string CreateComicInfo(Publication publication, Chapter chapter, Logger? logger)
{
- logger?.WriteLine("Connector", $"Creating ComicInfo.Xml for {publication.sortName} Chapter {chapter.volumeNumber} {chapter.chapterNumber}");
+ logger?.WriteLine("Connector", $"Creating ComicInfo.Xml for {publication.sortName} {publication.internalId} {chapter.volumeNumber}-{chapter.chapterNumber}");
XElement comicInfo = new XElement("ComicInfo",
new XElement("Tags", string.Join(',',publication.tags)),
new XElement("LanguageISO", publication.originalLanguage),
@@ -138,11 +138,12 @@ public abstract class Connector
/// List of URLs to download Images from
/// Full path to save archive to (without file ending .cbz)
/// DownloadClient of the connector
+ ///
/// Path of the generate Chapter ComicInfo.xml, if it was generated
/// RequestType for RateLimits
protected static void DownloadChapterImages(string[] imageUrls, string saveArchiveFilePath, DownloadClient downloadClient, byte requestType, Logger? logger, string? comicInfoPath = null)
{
- logger?.WriteLine("Connector", "Downloading Images");
+ logger?.WriteLine("Connector", $"Downloading Images for {saveArchiveFilePath}");
//Check if Publication Directory already exists
string directoryPath = Path.GetDirectoryName(saveArchiveFilePath)!;
if (!Directory.Exists(directoryPath))
@@ -160,13 +161,14 @@ public abstract class Connector
{
string[] split = imageUrl.Split('.');
string extension = split[^1];
+ logger?.WriteLine("Connector", $"Downloading Image {chapter + 1}/{imageUrls.Length}");
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"), downloadClient, requestType);
}
if(comicInfoPath is not null)
File.Copy(comicInfoPath, Path.Join(tempFolder, "ComicInfo.xml"));
- logger?.WriteLine("Connector", "Creating archive");
+ logger?.WriteLine("Connector", $"Creating archive {saveArchiveFilePath}");
//ZIP-it and ship-it
ZipFile.CreateFromDirectory(tempFolder, saveArchiveFilePath);
Directory.Delete(tempFolder, true); //Cleanup
@@ -228,6 +230,7 @@ public abstract class Connector
catch (HttpRequestException e)
{
logger?.WriteLine(this.GetType().ToString(), e.Message);
+ logger?.WriteLine(this.GetType().ToString(), $"Waiting {_rateLimit[requestType] * 2}");
Thread.Sleep(_rateLimit[requestType] * 2);
}
}
diff --git a/Tranga/Connectors/MangaDex.cs b/Tranga/Connectors/MangaDex.cs
index db36e2b..37beaac 100644
--- a/Tranga/Connectors/MangaDex.cs
+++ b/Tranga/Connectors/MangaDex.cs
@@ -55,6 +55,7 @@ public class MangaDex : Connector
total = result["total"]!.GetValue(); //Update the total number of Publications
JsonArray mangaInResult = result["data"]!.AsArray(); //Manga-data-Array
+ logger?.WriteLine(this.GetType().ToString(), $"Getting publication data.");
//Loop each Manga and extract information from JSON
foreach (JsonNode? mangeNode in mangaInResult)
{
@@ -142,12 +143,13 @@ public class MangaDex : Connector
}
}
+ logger?.WriteLine(this.GetType().ToString(), $"Done getting publications (title={publicationTitle})");
return publications.ToArray();
}
public override Chapter[] GetChapters(Publication publication, string language = "")
{
- logger?.WriteLine(this.GetType().ToString(), $"Getting Chapters {publication.sortName} (language={language})");
+ logger?.WriteLine(this.GetType().ToString(), $"Getting Chapters for {publication.sortName} {publication.internalId} (language={language})");
const int limit = 100; //How many values we want returned at once
int offset = 0; //"Page"
int total = int.MaxValue; //How many total results are there, is updated on first request
@@ -197,12 +199,13 @@ public class MangaDex : Connector
{
NumberDecimalSeparator = "."
};
+ logger?.WriteLine(this.GetType().ToString(), $"Done getting Chapters for {publication.internalId}");
return chapters.OrderBy(chapter => Convert.ToSingle(chapter.chapterNumber, chapterNumberFormatInfo)).ToArray();
}
public override void DownloadChapter(Publication publication, Chapter chapter)
{
- logger?.WriteLine(this.GetType().ToString(), $"Download Chapter {publication.sortName} {chapter.volumeNumber}-{chapter.chapterNumber}");
+ logger?.WriteLine(this.GetType().ToString(), $"Downloading Chapter-Info {publication.sortName} {publication.internalId} {chapter.volumeNumber}-{chapter.chapterNumber}");
//Request URLs for Chapter-Images
DownloadClient.RequestResult requestResult =
downloadClient.MakeRequest($"https://api.mangadex.org/at-home/server/{chapter.url}?forcePort443=false'", (byte)RequestType.AtHomeServer);
@@ -229,9 +232,10 @@ public class MangaDex : Connector
private string? GetCoverUrl(string publicationId, string? posterId)
{
+ logger?.WriteLine(this.GetType().ToString(), $"Getting CoverUrl for {publicationId}");
if (posterId is null)
{
- logger?.WriteLine(this.GetType().ToString(), $"No posterId");
+ logger?.WriteLine(this.GetType().ToString(), $"No posterId, aborting");
return null;
}
@@ -247,6 +251,7 @@ public class MangaDex : Connector
string fileName = result["data"]!["attributes"]!["fileName"]!.GetValue();
string coverUrl = $"https://uploads.mangadex.org/covers/{publicationId}/{fileName}";
+ logger?.WriteLine(this.GetType().ToString(), $"Got Cover-Url for {publicationId} -> {coverUrl}");
return coverUrl;
}
@@ -264,6 +269,7 @@ public class MangaDex : Connector
return null;
string author = result["data"]!["attributes"]!["name"]!.GetValue();
+ logger?.WriteLine(this.GetType().ToString(), $"Got author {authorId} -> {author}");
return author;
}
@@ -286,8 +292,6 @@ public class MangaDex : Connector
string newFilePath = Path.Join(publicationFolder, $"cover.{Path.GetFileName(fileInCache).Split('.')[^1]}" );
logger?.WriteLine(this.GetType().ToString(), $"Cloning cover {fileInCache} -> {newFilePath}");
File.Copy(fileInCache, newFilePath, true);
- logger?.WriteLine(this.GetType().ToString(), $"Done cloning cover {publication.sortName}");
-
}
private string SaveImage(string url)
@@ -303,6 +307,7 @@ public class MangaDex : Connector
using MemoryStream ms = new();
coverResult.result.CopyTo(ms);
File.WriteAllBytes(saveImagePath, ms.ToArray());
+ logger?.WriteLine(this.GetType().ToString(), $"Saving image to {saveImagePath}");
return filename;
}
}
\ No newline at end of file