Moved GetNewChaptersList to taskManager and added GetExistingChaptersList
This commit is contained in:
parent
088d1c4647
commit
b571bfa43d
@ -372,6 +372,31 @@ public class TaskManager
|
|||||||
return this.chapterCollection.Keys.ToArray();
|
return this.chapterCollection.Keys.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the available Chapters of a Publication
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="connector">Connector to use</param>
|
||||||
|
/// <param name="publication">Publication to check</param>
|
||||||
|
/// <param name="language">Language to receive chapters for</param>
|
||||||
|
/// <returns>List of Chapters that were previously not in collection</returns>
|
||||||
|
public List<Chapter> GetNewChaptersList(Connector connector, Publication publication, string language)
|
||||||
|
{
|
||||||
|
List<Chapter> newChaptersList = new();
|
||||||
|
chapterCollection.TryAdd(publication, newChaptersList); //To ensure publication is actually in collection
|
||||||
|
|
||||||
|
Chapter[] newChapters = connector.GetChapters(publication, language);
|
||||||
|
newChaptersList = newChapters.Where(nChapter => !connector.CheckChapterIsDownloaded(publication, nChapter)).ToList();
|
||||||
|
|
||||||
|
return newChaptersList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Chapter> GetExistingChaptersList(Connector connector, Publication publication, string language)
|
||||||
|
{
|
||||||
|
Chapter[] newChapters = connector.GetChapters(publication, language);
|
||||||
|
return newChapters.Where(nChapter => connector.CheckChapterIsDownloaded(publication, nChapter)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return Connector with given Name
|
/// Return Connector with given Name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -24,7 +24,7 @@ public class DownloadNewChaptersTask : TrangaTask
|
|||||||
|
|
||||||
//Check if Publication already has a Folder
|
//Check if Publication already has a Folder
|
||||||
pub.CreatePublicationFolder(taskManager.settings.downloadLocation);
|
pub.CreatePublicationFolder(taskManager.settings.downloadLocation);
|
||||||
List<Chapter> newChapters = GetNewChaptersList(connector, pub, language!, ref taskManager.chapterCollection);
|
List<Chapter> newChapters = taskManager.GetNewChaptersList(connector, pub, language!);
|
||||||
|
|
||||||
connector.CopyCoverFromCacheToDownloadLocation(pub, taskManager.settings);
|
connector.CopyCoverFromCacheToDownloadLocation(pub, taskManager.settings);
|
||||||
|
|
||||||
@ -38,25 +38,6 @@ public class DownloadNewChaptersTask : TrangaTask
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the available Chapters of a Publication
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="connector">Connector to use</param>
|
|
||||||
/// <param name="publication">Publication to check</param>
|
|
||||||
/// <param name="language">Language to receive chapters for</param>
|
|
||||||
/// <param name="chapterCollection"></param>
|
|
||||||
/// <returns>List of Chapters that were previously not in collection</returns>
|
|
||||||
private static List<Chapter> GetNewChaptersList(Connector connector, Publication publication, string language, ref Dictionary<Publication, List<Chapter>> chapterCollection)
|
|
||||||
{
|
|
||||||
List<Chapter> newChaptersList = new();
|
|
||||||
chapterCollection.TryAdd(publication, newChaptersList); //To ensure publication is actually in collection
|
|
||||||
|
|
||||||
Chapter[] newChapters = connector.GetChapters(publication, language);
|
|
||||||
newChaptersList = newChapters.Where(nChapter => !connector.CheckChapterIsDownloaded(publication, nChapter)).ToList();
|
|
||||||
|
|
||||||
return newChaptersList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{base.ToString()}, {connectorName}, {publication.sortName} {publication.internalId}";
|
return $"{base.ToString()}, {connectorName}, {publication.sortName} {publication.internalId}";
|
||||||
|
Loading…
Reference in New Issue
Block a user