Skip to content

Commit a18f09c

Browse files
committed
v1.3
1 parent 01debc7 commit a18f09c

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change log
22

3+
## v1.3
4+
5+
### Changed
6+
- Update of the 'aggColumnUsername' function
7+
8+
### Added:
9+
- Added "deleteEmbed" function that deletes all tweets from all columns
10+
311
## v1.2
412

513
### New Features
@@ -9,10 +17,10 @@
917
### Changed
1018
- Update of the 'README.md' file
1119

12-
### Feature Change **
20+
### Feature Change
1321
- Taking into account the number of columns in the page Notion in a dynamic way
1422

15-
### Added: **
23+
### Added:
1624
- Added "checkTwitterUsername" function that checks if a Twitter user exists
1725
- Added "getUsernames" function that retrieves the username in the column title of the Notion page
1826
- Added function "aggColumnUsername" which calls sub-functions that check that the username exists on twitter and that the title of the column is of type "heading_1

main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,27 @@ def appendEmbed(tweet_ids,username,column_id):
7575

7676
return ReturnCode
7777

78+
#Function that retrieves the id of the blocks that contain a tweet and deletes them
79+
def deleteEmbed(columns_id):
80+
81+
82+
embed_blocks_id = []
83+
# Get the id of the 'embed' blocks that contain a twitter link
84+
for column_id in columns_id:
85+
url_block_column = f"https://api.notion.com/v1/blocks/{column_id}/children"
86+
blocks = json.loads(requests.request("GET", url_block_column, headers=headers).text)
87+
88+
for block in blocks["results"]:
89+
# If the type of the block is "embed" and the url it contains starts with 'https://twitter.com/' then we copy its id
90+
if block["type"] == "embed" and block["embed"]["url"].startswith('https://twitter.com/'):
91+
embed_blocks_id.append(block["id"])
92+
93+
for embed_block_id in embed_blocks_id:
94+
95+
url_block_embed = f"https://api.notion.com/v1/blocks/{embed_block_id}"
96+
97+
requests.request("DELETE", url_block_embed, headers=headers)
98+
7899
#Function that checks if the column title is heading 1 and if the twitter username exists
79100
#if this is not the case the id of the column is not kept.
80101

@@ -83,6 +104,7 @@ def aggColumnUsername():
83104
agg_return = [[],[]]
84105

85106
ColumnIDs = getColumnIDs()
107+
deleteEmbed(ColumnIDs)
86108
Usernames = getUsernames(ColumnIDs)
87109

88110
for index,username in enumerate(Usernames):

0 commit comments

Comments
 (0)