|
| 1 | +# NotionExporter |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +`NotionExporter` is a Python class designed to simplify the process of exporting content from Notion. It provides an interface to configure, trigger, and download content exports from Notion. The class supports exporting content in various formats (Markdown, HTML, PDF) and also allows users to choose the scope of the export (current view vs. all content). |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Export content in **Markdown**, **HTML**, or **PDF** format. |
| 10 | +- Configure the scope of your export: **current view** or **all content**. |
| 11 | +- Option to include or exclude files in the export. |
| 12 | +- Flatten the file tree structure upon export. |
| 13 | +- Export multiple pages concurrently for faster processing. |
| 14 | +- Monitor export progress with a progress bar. |
| 15 | +- Automatically unpack zipped export files. |
| 16 | + |
| 17 | +## Requirements |
| 18 | + |
| 19 | +- Python 3.6+ |
| 20 | +- Dependencies: |
| 21 | + - `enum` |
| 22 | + - `os` |
| 23 | + - `json` |
| 24 | + - `requests` |
| 25 | + - `datetime` |
| 26 | + - `multiprocessing` |
| 27 | + - `logging` |
| 28 | + - `time` |
| 29 | + - `shutil` |
| 30 | + - `tqdm` |
| 31 | + |
| 32 | +Make sure to install the necessary libraries using `pip`. |
| 33 | + |
| 34 | +## Usage |
| 35 | + |
| 36 | +1. **Initialization**: |
| 37 | + |
| 38 | + ```python |
| 39 | + exporter = NotionExporter( |
| 40 | + token_v2="YOUR_NOTION_TOKEN", |
| 41 | + file_token="YOUR_FILE_TOKEN", |
| 42 | + pages={"Page Name": "Page ID"}, |
| 43 | + export_directory="path/to/save", |
| 44 | + flatten_export_file_tree=True, |
| 45 | + export_type=ExportType.MARKDOWN, |
| 46 | + current_view_export_type=ViewExportType.CURRENT_VIEW, |
| 47 | + include_files=True, |
| 48 | + recursive=True |
| 49 | + ) |
| 50 | + ``` |
| 51 | + |
| 52 | + You will need to get the `token_v2` and `file_token` values from your Notion cookies. The `pages` dictionary should contain pairs of `page_name: page_id` for each page you want to export. |
| 53 | + |
| 54 | +2. **Process Exports**: |
| 55 | + |
| 56 | + ```python |
| 57 | + exporter.process() |
| 58 | + ``` |
| 59 | + |
| 60 | + This will initiate the export, download, and unpacking processes for the pages defined. |
| 61 | + |
| 62 | +For more details or any issues, please raise a ticket or contact the maintainers. |
0 commit comments