Rewrote CoverDownload check if exists.
This commit is contained in:
parent
30b6c4680b
commit
9a640aed27
@ -270,29 +270,26 @@ public class MangaDex : Connector
|
|||||||
if(!Directory.Exists(publicationFolder))
|
if(!Directory.Exists(publicationFolder))
|
||||||
Directory.CreateDirectory(publicationFolder);
|
Directory.CreateDirectory(publicationFolder);
|
||||||
DirectoryInfo dirInfo = new (publicationFolder);
|
DirectoryInfo dirInfo = new (publicationFolder);
|
||||||
foreach(FileInfo fileInfo in dirInfo.EnumerateFiles())
|
if (dirInfo.EnumerateFiles().Any(info => info.Name.Contains("cover.")))
|
||||||
if (fileInfo.Name.Contains("cover."))
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Cover exists {publication.sortName}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (publication.posterUrl is null)
|
|
||||||
{
|
{
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"No posterurl in publication");
|
logger?.WriteLine(this.GetType().ToString(), $"Cover exists {publication.sortName}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string coverUrl = publication.posterUrl;
|
if (publication.posterUrl is null || !(bool)publication.posterUrl?.Contains("http"))
|
||||||
|
{
|
||||||
|
logger?.WriteLine(this.GetType().ToString(), $"No Poster-URL in publication");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Get file-extension (jpg, png)
|
//Get file-extension (jpg, png)
|
||||||
string[] split = coverUrl.Split('.');
|
string[] split = publication.posterUrl.Split('.');
|
||||||
string extension = split[^1];
|
string extension = split[^1];
|
||||||
|
|
||||||
string outFolderPath = Path.Join(downloadLocation, publication.folderName);
|
string outFolderPath = Path.Join(downloadLocation, publication.folderName);
|
||||||
Directory.CreateDirectory(outFolderPath);
|
Directory.CreateDirectory(outFolderPath);
|
||||||
|
|
||||||
//Download cover-Image
|
//Download cover-Image
|
||||||
DownloadImage(coverUrl, Path.Join(downloadLocation, publication.folderName, $"cover.{extension}"), this.downloadClient, (byte)RequestType.AtHomeServer);
|
DownloadImage(publication.posterUrl, Path.Join(downloadLocation, publication.folderName, $"cover.{extension}"), this.downloadClient, (byte)RequestType.AtHomeServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user