scrapeAllPages method
Future<void>
scrapeAllPages(
{ - required int latestTotalPages,
- required int cachedTotalPages,
})
Implementation
Future<void> scrapeAllPages({
required int latestTotalPages,
required int cachedTotalPages,
}) async {
int count = 0;
for (int page = latestTotalPages - cachedTotalPages; page >= 1; page--) {
print('Scraping page $page');
await AudioBookBayApi()
.find(SearchRequest(query: '', page: page))
.then((response) async {
for (final book in response.books) {
// print(book.title);
await compute(saveAudiobook, book);
}
});
count += 1;
final save = await updateSyncHistory(
AudioBookSyncHistory(totalPages: cachedTotalPages + count),
);
if (!save) {
print('Failed to save sync history');
break;
}
}
}