diff --git a/Tranga/Connector.cs b/Tranga/Connector.cs
index c2263ee..0ff35ed 100644
--- a/Tranga/Connector.cs
+++ b/Tranga/Connector.cs
@@ -55,12 +55,13 @@ public abstract class Connector
/// Publication that contains Chapter
/// Chapter with Images to retrieve
public abstract void DownloadChapter(Publication publication, Chapter chapter);
-
+
///
/// Retrieves the Cover from the Website
///
/// Publication to retrieve Cover for
- public abstract void DownloadCover(Publication publication);
+ /// TrangaSettings
+ public abstract void CloneCoverFromCache(Publication publication, TrangaSettings settings);
///
/// Saves the series-info to series.json in the Publication Folder
diff --git a/Tranga/Connectors/MangaDex.cs b/Tranga/Connectors/MangaDex.cs
index 0325063..d8a247a 100644
--- a/Tranga/Connectors/MangaDex.cs
+++ b/Tranga/Connectors/MangaDex.cs
@@ -267,11 +267,12 @@ public class MangaDex : Connector
return author;
}
- public override void DownloadCover(Publication publication)
+ public override void CloneCoverFromCache(Publication publication, TrangaSettings settings)
{
- logger?.WriteLine(this.GetType().ToString(), $"Download cover {publication.sortName}");
+ logger?.WriteLine(this.GetType().ToString(), $"Cloning cover {publication.sortName}");
//Check if Publication already has a Folder and cover
string publicationFolder = Path.Join(downloadLocation, publication.folderName);
+
if(!Directory.Exists(publicationFolder))
Directory.CreateDirectory(publicationFolder);
DirectoryInfo dirInfo = new (publicationFolder);
@@ -281,21 +282,11 @@ public class MangaDex : Connector
return;
}
- if (publication.posterUrl is null || publication.posterUrl!.Contains("http"))
- {
- logger?.WriteLine(this.GetType().ToString(), $"No Poster-URL in publication");
- return;
- }
-
- //Get file-extension (jpg, png)
- string[] split = publication.posterUrl.Split('.');
- string extension = split[^1];
-
- string outFolderPath = Path.Join(downloadLocation, publication.folderName);
- Directory.CreateDirectory(outFolderPath);
+ string fileInCache = Path.Join(settings.coverImageCache, publication.coverFileNameInCache);
+ string newFilePath = Path.Join(publicationFolder, Path.GetFileName(fileInCache));
+ if(File.Exists(fileInCache))
+ File.Copy(fileInCache, newFilePath);
- //Download cover-Image
- DownloadImage(publication.posterUrl, Path.Join(downloadLocation, publication.folderName, $"cover.{extension}"), this.downloadClient, (byte)RequestType.AtHomeServer);
}
private string SaveImage(string url)
diff --git a/Tranga/TaskExecutor.cs b/Tranga/TaskExecutor.cs
index 0993bac..b9cd75b 100644
--- a/Tranga/TaskExecutor.cs
+++ b/Tranga/TaskExecutor.cs
@@ -37,7 +37,7 @@ public static class TaskExecutor
switch (trangaTask.task)
{
case TrangaTask.Task.DownloadNewChapters:
- DownloadNewChapters(connector!, (Publication)trangaTask.publication!, trangaTask.language, ref taskManager._chapterCollection);
+ DownloadNewChapters(connector!, (Publication)trangaTask.publication!, trangaTask.language, ref taskManager._chapterCollection, taskManager.settings);
break;
case TrangaTask.Task.UpdateChapters:
UpdateChapters(connector!, (Publication)trangaTask.publication!, trangaTask.language, ref taskManager._chapterCollection);
@@ -90,7 +90,7 @@ public static class TaskExecutor
/// Publication to check
/// Language to receive chapters for
///
- private static void DownloadNewChapters(Connector connector, Publication publication, string language, ref Dictionary> chapterCollection)
+ private static void DownloadNewChapters(Connector connector, Publication publication, string language, ref Dictionary> chapterCollection, TrangaSettings settings)
{
//Check if Publication already has a Folder
string publicationFolder = Path.Join(connector.downloadLocation, publication.folderName);
@@ -98,7 +98,7 @@ public static class TaskExecutor
Directory.CreateDirectory(publicationFolder);
List newChapters = UpdateChapters(connector, publication, language, ref chapterCollection);
- connector.DownloadCover(publication);
+ connector.CloneCoverFromCache(publication, settings);
string seriesInfoPath = Path.Join(publicationFolder, "series.json");
if(!File.Exists(seriesInfoPath))