notebooklm-sdk 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.cjs +28 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -137,6 +137,7 @@ npx notebooklm-sdk login
|
|
|
137
137
|
bun run examples/basic.ts # list notebooks and sources
|
|
138
138
|
bun run examples/chat.ts # ask questions, follow-up conversations
|
|
139
139
|
bun run examples/audio.ts # generate and download a podcast
|
|
140
|
+
bun run examples/video.ts # generate and download a cinematic video
|
|
140
141
|
bun run examples/report.ts # generate and download a briefing doc
|
|
141
142
|
bun run examples/slide-deck.ts # generate and download PDF / PPTX
|
|
142
143
|
bun run examples/infographic.ts # generate and download a PNG infographic
|
package/dist/index.cjs
CHANGED
|
@@ -940,9 +940,23 @@ ${opts.extraInstructions}` : cfg.prompt;
|
|
|
940
940
|
// Polling / download
|
|
941
941
|
// ---------------------------------------------------------------------------
|
|
942
942
|
/** Poll until artifact reaches completed/failed status. */
|
|
943
|
-
async waitUntilReady(notebookId, artifactId, timeout =
|
|
943
|
+
async waitUntilReady(notebookId, artifactId, timeout = 1800, pollInterval = 3) {
|
|
944
|
+
return this.pollUntilReady(notebookId, artifactId, {
|
|
945
|
+
timeoutSecs: timeout,
|
|
946
|
+
intervalSecs: pollInterval
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
/** Poll until artifact is fully ready, with optional progress hooks and cancellation. */
|
|
950
|
+
async pollUntilReady(notebookId, artifactId, opts = {}) {
|
|
951
|
+
const timeout = opts.timeoutSecs ?? 1800;
|
|
952
|
+
const pollInterval = opts.intervalSecs ?? 3;
|
|
944
953
|
const deadline = Date.now() + timeout * 1e3;
|
|
954
|
+
let lastStatus = null;
|
|
945
955
|
while (Date.now() < deadline) {
|
|
956
|
+
this.throwIfAborted(opts.signal);
|
|
957
|
+
const status = await this.pollStatus(notebookId, artifactId);
|
|
958
|
+
lastStatus = status;
|
|
959
|
+
if (opts.onTick) await opts.onTick(status);
|
|
946
960
|
const artifact = await this.get(notebookId, artifactId);
|
|
947
961
|
if (artifact?.status === "completed") {
|
|
948
962
|
if (artifact.kind === "audio" && !artifact.audioUrl || artifact.kind === "video" && !artifact.videoUrl) {
|
|
@@ -951,12 +965,22 @@ ${opts.extraInstructions}` : cfg.prompt;
|
|
|
951
965
|
}
|
|
952
966
|
return artifact;
|
|
953
967
|
}
|
|
954
|
-
if (artifact?.status === "failed") {
|
|
955
|
-
throw new ArtifactNotReadyError(artifact
|
|
968
|
+
if (artifact?.status === "failed" || status.status === "failed") {
|
|
969
|
+
throw new ArtifactNotReadyError(artifact?.kind ?? "artifact", {
|
|
970
|
+
artifactId,
|
|
971
|
+
status: "failed"
|
|
972
|
+
});
|
|
956
973
|
}
|
|
957
974
|
await sleep(pollInterval * 1e3);
|
|
958
975
|
}
|
|
959
|
-
throw new ArtifactNotReadyError("artifact", {
|
|
976
|
+
throw new ArtifactNotReadyError("artifact", {
|
|
977
|
+
artifactId,
|
|
978
|
+
status: lastStatus?.status ?? "timeout"
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
throwIfAborted(signal) {
|
|
982
|
+
if (!signal?.aborted) return;
|
|
983
|
+
throw new Error("Artifact polling aborted");
|
|
960
984
|
}
|
|
961
985
|
/** Get the current status of a generated artifact without waiting. */
|
|
962
986
|
async pollStatus(notebookId, artifactId) {
|