Create Publication Folder and replace downloaded files if necessary.

This commit is contained in:
glax
2023-05-18 18:43:22 +02:00
parent d191f5dfc7
commit d46b46f8fb
2 changed files with 12 additions and 6 deletions

View File

@ -12,7 +12,7 @@ public abstract class Connector
public abstract void DownloadChapter(Publication publication, Chapter chapter); //where to?
internal abstract void DownloadImage(string url, string path);
internal void DownloadChapter(string[] imageUrls, string outputFolderPath)
internal void DownloadChapter(string[] imageUrls, string outputFilePath)
{
string tempFolder = Path.GetTempFileName();
File.Delete(tempFolder);
@ -24,10 +24,16 @@ public abstract class Connector
string[] split = imageUrl.Split('.');
string extension = split[split.Length - 1];
DownloadImage(imageUrl, Path.Join(tempFolder, $"{chapter++}.{extension}"));
}
ZipFile.CreateFromDirectory(tempFolder, $"{outputFolderPath}.cbz");
string[] splitPath = outputFilePath.Split(Path.DirectorySeparatorChar);
string directoryPath = Path.Combine(splitPath.Take(splitPath.Length - 1).ToArray());
if (!Directory.Exists(directoryPath))
Directory.CreateDirectory(directoryPath);
string fullPath = $"{outputFilePath}.cbz";
File.Delete(fullPath);
ZipFile.CreateFromDirectory(tempFolder, fullPath);
}
internal class DownloadClient