Add a new notebook to the library Args: url: NotebookLM notebook URL name: Display name for the notebook description: What's in this notebook topics: Topics covered content_types: Types of content (optional) us
(
self,
url: str,
name: str,
description: str,
topics: List[str],
content_types: Optional[List[str]] = None,
use_cases: Optional[List[str]] = None,
tags: Optional[List[str]] = None
)
| 61 | print(f"❌ Error saving library: {e}") |
| 62 | |
| 63 | def add_notebook( |
| 64 | self, |
| 65 | url: str, |
| 66 | name: str, |
| 67 | description: str, |
| 68 | topics: List[str], |
| 69 | content_types: Optional[List[str]] = None, |
| 70 | use_cases: Optional[List[str]] = None, |
| 71 | tags: Optional[List[str]] = None |
| 72 | ) -> Dict[str, Any]: |
| 73 | """ |
| 74 | Add a new notebook to the library |
| 75 | |
| 76 | Args: |
| 77 | url: NotebookLM notebook URL |
| 78 | name: Display name for the notebook |
| 79 | description: What's in this notebook |
| 80 | topics: Topics covered |
| 81 | content_types: Types of content (optional) |
| 82 | use_cases: When to use this notebook (optional) |
| 83 | tags: Additional tags for organization (optional) |
| 84 | |
| 85 | Returns: |
| 86 | The created notebook object |
| 87 | """ |
| 88 | # Generate ID from name |
| 89 | notebook_id = name.lower().replace(' ', '-').replace('_', '-') |
| 90 | |
| 91 | # Check for duplicates |
| 92 | if notebook_id in self.notebooks: |
| 93 | raise ValueError(f"Notebook with ID '{notebook_id}' already exists") |
| 94 | |
| 95 | # Create notebook object |
| 96 | notebook = { |
| 97 | 'id': notebook_id, |
| 98 | 'url': url, |
| 99 | 'name': name, |
| 100 | 'description': description, |
| 101 | 'topics': topics, |
| 102 | 'content_types': content_types or [], |
| 103 | 'use_cases': use_cases or [], |
| 104 | 'tags': tags or [], |
| 105 | 'created_at': datetime.now().isoformat(), |
| 106 | 'updated_at': datetime.now().isoformat(), |
| 107 | 'use_count': 0, |
| 108 | 'last_used': None |
| 109 | } |
| 110 | |
| 111 | # Add to library |
| 112 | self.notebooks[notebook_id] = notebook |
| 113 | |
| 114 | # Set as active if it's the first notebook |
| 115 | if len(self.notebooks) == 1: |
| 116 | self.active_notebook_id = notebook_id |
| 117 | |
| 118 | self._save_library() |
| 119 | |
| 120 | print(f"✅ Added notebook: {name} ({notebook_id})") |