Skip to content

Commit 6f1d3aa

Browse files
committed
fix: handle YouTube URLs correctly in importResearchSources
YouTube URLs need to go in index 7 as [url] array, not index 2. Also filters out sources without URLs to prevent batch failures. Matched format from live HAR capture of Import+ button.
1 parent f12e233 commit 6f1d3aa

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/services/notebooklm/client.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,19 +503,16 @@ export class NotebookLMClient {
503503
`[NotebookLM] Importing ${sources.length} research sources into notebook ${notebookId}`
504504
);
505505

506-
const sourceArray = sources.map((s) => [
507-
null,
508-
null,
509-
[s.url, s.title],
510-
null,
511-
null,
512-
null,
513-
null,
514-
null,
515-
null,
516-
null,
517-
2,
518-
]);
506+
const sourceArray = sources
507+
.filter((s) => s.url) // Skip sources without URLs
508+
.map((s) => {
509+
if (isYouTubeUrl(s.url)) {
510+
// YouTube URLs go in index 7 as [url] array
511+
return [null, null, null, null, null, null, null, [s.url], null, null, 2];
512+
}
513+
// Regular URLs go in index 2 as [url, title]
514+
return [null, null, [s.url, s.title || 'Untitled'], null, null, null, null, null, null, null, 2];
515+
});
519516

520517
await this.rpcCall(RPCMethod.IMPORT_RESEARCH, [
521518
null,

0 commit comments

Comments
 (0)