import { getBooks, updateBookMetadata } from 'komga-sdk';
const listed = await getBooks(
{
page: 0,
size: 50,
sort: ['metadata.title,asc'],
bookSearch: { fullTextSearch: 'classic' },
},
{ client },
);
if (listed.error) throw listed.error;
const updatedIds: string[] = [];
for (const book of listed.data?.content ?? []) {
const updated = await updateBookMetadata(
{
bookId: book.id,
bookMetadataUpdateDto: { summary: 'Curated collection' },
},
{ client },
);
if (updated.error) {
console.error(`Could not update ${book.id}`, updated.error);
} else {
updatedIds.push(book.id);
}
}
console.log(`Updated ${updatedIds.length} books`);