feat(scripts): novel details (chapters, free/locked, author, status) for the request page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Details of one novel on one source, for the request page: chapter counts (free vs
|
||||
// locked 🔒), latest chapter, author, status, genres, summary and cover.
|
||||
// Usage: node scripts/novel-info.js <plugin-id> <novel-path> -> one JSON line
|
||||
import { loadPlugin, print } from './load-plugins.js';
|
||||
|
||||
const [pluginId, novelPath] = process.argv.slice(2);
|
||||
if (!pluginId || !novelPath) {
|
||||
console.error('Usage: node scripts/novel-info.js <plugin-id> <novel-path>');
|
||||
process.exit(2);
|
||||
}
|
||||
const plugin = await loadPlugin(pluginId);
|
||||
const novel = await plugin.parseNovel(novelPath);
|
||||
const chapters = novel.chapters || [];
|
||||
const firstLocked = chapters.findIndex(c => c.name.includes('🔒'));
|
||||
print(
|
||||
JSON.stringify({
|
||||
name: novel.name,
|
||||
cover: novel.cover || null,
|
||||
author: novel.author || null,
|
||||
status: novel.status || null,
|
||||
genres: novel.genres || null,
|
||||
summary: (novel.summary || '').slice(0, 1200),
|
||||
chapters: chapters.length,
|
||||
free: firstLocked < 0 ? chapters.length : firstLocked,
|
||||
latest: chapters.length ? chapters[chapters.length - 1].name : null,
|
||||
}),
|
||||
);
|
||||
process.exit(0);
|
||||
Reference in New Issue
Block a user