Skip to content

Commit 2e81908

Browse files
author
Per Halvorsen
committed
add funtion to update db with local files
1 parent 66f81d7 commit 2e81908

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

home/notion.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,24 @@ async def album_check():
295295

296296
asyncio.run(album_check())
297297

298-
breakpoint()
298+
299+
from pathlib import Path
300+
301+
async def update_album_from_local():
302+
album_dir = Path("home/static/img/.hide/")
303+
304+
# get all .jpg files
305+
jpg_files = sorted(album_dir.glob("*.jpg"))
306+
307+
for i, jpg_file in enumerate(jpg_files):
308+
data = dict(
309+
Name={"title": [{"text": {"content": jpg_file.stem}}]},
310+
URL={"url": f"/static/img/.hide/{jpg_file.name}"},
311+
Order={"number": int(jpg_file.stem.split("_")[-1])}
312+
)
313+
314+
response = await notion_db_client.update_database(env.notion_sitedb_wedding_album_id, data)
315+
316+
if i > 4:
317+
break
318+

0 commit comments

Comments
 (0)