Compare commits
3 Commits
08e0fe7c71
...
621468f498
Author | SHA1 | Date | |
---|---|---|---|
621468f498 | |||
2c8e647a04 | |||
9d583b284a |
@ -78,6 +78,16 @@ public abstract class Connector
|
|||||||
return comicInfo.ToString();
|
return comicInfo.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ChapterIsDownloaded(Publication publication, Chapter chapter)
|
||||||
|
{
|
||||||
|
return File.Exists(CreateFullFilepath(publication, chapter));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected string CreateFullFilepath(Publication publication, Chapter chapter)
|
||||||
|
{
|
||||||
|
return Path.Join(downloadLocation, publication.folderName, chapter.fileName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Downloads Image from URL and saves it to the given path(incl. fileName)
|
/// Downloads Image from URL and saves it to the given path(incl. fileName)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -201,7 +201,7 @@ public class MangaDex : Connector
|
|||||||
File.WriteAllText(comicInfoPath, CreateComicInfo(publication, chapter));
|
File.WriteAllText(comicInfoPath, CreateComicInfo(publication, chapter));
|
||||||
|
|
||||||
//Download Chapter-Images
|
//Download Chapter-Images
|
||||||
DownloadChapterImages(imageUrls.ToArray(), Path.Join(downloadLocation, publication.folderName, chapter.fileName), this.downloadClient, comicInfoPath);
|
DownloadChapterImages(imageUrls.ToArray(), CreateFullFilepath(publication, chapter), downloadClient, comicInfoPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DownloadCover(Publication publication)
|
public override void DownloadCover(Publication publication)
|
||||||
|
@ -33,7 +33,7 @@ public readonly struct Publication
|
|||||||
this.originalLanguage = originalLanguage;
|
this.originalLanguage = originalLanguage;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.downloadUrl = downloadUrl;
|
this.downloadUrl = downloadUrl;
|
||||||
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars()));
|
this.folderName = string.Concat(sortName.Split(Path.GetInvalidPathChars().Concat(Path.GetInvalidFileNameChars()).ToArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -93,14 +93,11 @@ public static class TaskExecutor
|
|||||||
private static List<Chapter> UpdateChapters(Connector connector, Publication publication, string language, Dictionary<Publication, List<Chapter>> chapterCollection)
|
private static List<Chapter> UpdateChapters(Connector connector, Publication publication, string language, Dictionary<Publication, List<Chapter>> chapterCollection)
|
||||||
{
|
{
|
||||||
List<Chapter> newChaptersList = new();
|
List<Chapter> newChaptersList = new();
|
||||||
if (!chapterCollection.ContainsKey(publication))
|
chapterCollection.TryAdd(publication, newChaptersList); //To ensure publication is actually in collection
|
||||||
return newChaptersList;
|
|
||||||
|
|
||||||
List<Chapter> currentChapters = chapterCollection[publication];
|
|
||||||
Chapter[] newChapters = connector.GetChapters(publication, language);
|
Chapter[] newChapters = connector.GetChapters(publication, language);
|
||||||
|
newChaptersList = newChapters.Where(nChapter => !connector.ChapterIsDownloaded(publication, nChapter)).ToList();
|
||||||
|
|
||||||
newChaptersList = newChapters.ToList()
|
|
||||||
.ExceptBy(currentChapters.Select(cChapter => cChapter.url), nChapter => nChapter.url).ToList();
|
|
||||||
return newChaptersList;
|
return newChaptersList;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user