forked from axyyu/notion-clear-trash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Wang
authored and
Andrew Wang
committed
Jul 9, 2019
0 parents
commit 6258f1b
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__pycache__/* | ||
.vscode/* | ||
env/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# notion-clear-trash | ||
|
||
A small script to clear the trash from Notion | ||
|
||
### How to Run the Script | ||
|
||
1. Clone the repository | ||
```bash | ||
git clone https://github.com/w4v3s/notion-clear-trash.git | ||
``` | ||
2. Install requirements | ||
```bash | ||
pip3 install -r requirements.txt | ||
``` | ||
3. Run python script | ||
```bash | ||
python3 notion-clear-trash.py | ||
``` | ||
|
||
### How to Retrieve the Auth Token (in Chrome) | ||
|
||
1. Go to notion.so | ||
2. Open developer tools (hit F12) | ||
3. Navigate to the Application tab (may be hidden if the developer window is small) | ||
4. Expand Cookies under the Storage section on the sidebar | ||
5. Click on 'https://www.notion.so' to view all the cookies | ||
6. Copy the value for the key 'token_v2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from notion.client import NotionClient | ||
|
||
|
||
def get_trash(client): | ||
query = { | ||
'query': '', | ||
'limit': 1000, | ||
'spaceId': client.current_space.id | ||
} | ||
results = client.post('searchTrashPages', query) | ||
block_ids = results.json()['results'] | ||
|
||
return block_ids | ||
|
||
|
||
def delete_permanently(client, block_ids): | ||
for block_id in block_ids: | ||
client.post("deleteBlocks", {"blockIds": [block_id], "permanentlyDelete": True}) | ||
|
||
|
||
if __name__== "__main__": | ||
token = input('Please enter your auth token: ') | ||
client = NotionClient(token_v2=token) | ||
|
||
block_ids = get_trash(client) | ||
delete_permanently(client, block_ids) | ||
|
||
print('Successfully cleared all trash blocks.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
beautifulsoup4==4.7.1 | ||
bs4==0.0.1 | ||
cached-property==1.5.1 | ||
certifi==2019.6.16 | ||
chardet==3.0.4 | ||
commonmark==0.9.0 | ||
dictdiffer==0.8.0 | ||
future==0.17.1 | ||
idna==2.8 | ||
notion==0.0.23 | ||
python-slugify==3.0.2 | ||
pytz==2019.1 | ||
requests==2.22.0 | ||
soupsieve==1.9.2 | ||
text-unidecode==1.2 | ||
tzlocal==1.5.1 | ||
urllib3==1.25.3 |