Create Publication Folder and replace downloaded files if necessary.
This commit is contained in:
parent
d191f5dfc7
commit
d46b46f8fb
@ -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
|
||||
|
@ -178,9 +178,9 @@ public class MangaDex : Connector
|
||||
foreach (JsonNode image in imageFileNames)
|
||||
imageUrls.Add($"{baseUrl}/data/{hash}/{image!.GetValue<string>()}");
|
||||
|
||||
string fileName = string.Concat(publication.sortName.Split(Path.GetInvalidFileNameChars()));
|
||||
string seriesFolder = string.Concat(publication.sortName.Split(Path.GetInvalidPathChars()));
|
||||
|
||||
DownloadChapter(imageUrls.ToArray(), Path.Join(downloadLocation, fileName));
|
||||
DownloadChapter(imageUrls.ToArray(), Path.Join(downloadLocation, seriesFolder, chapter.relativeFilePath));
|
||||
}
|
||||
|
||||
internal override void DownloadImage(string url, string path)
|
||||
|
Loading…
Reference in New Issue
Block a user