minwook-shin / notion-database

Python bindings for Notion Database API
https://pypi.org/project/notion-database/
GNU Lesser General Public License v3.0
137 stars 12 forks source link

how to add Page icons or Cover Images? #14

Closed 668168 closed 1 year ago

668168 commented 1 year ago

ref: https://developers.notion.com/changelog/page-icons-cover-images-new-block-types-and-improved-page-file-properties https://developers.notion.com/reference/post-page

minwook-shin commented 1 year ago

hello, @668168 thank you for using package. cover and icon are not yet supported. but develop has started and will be added in next version. (with previous issue bug fix)

minwook-shin commented 1 year ago

@668168 Added a new feature for this issue.

# prepare object
cover = Cover()
cover.set_cover_image("https://github.githubassets.com/images/modules/logos_page/Octocat.png")
icon = Icon()
icon.set_icon_emoji("📚")

# use this (cover=cover, icon=icon)
D.create_database(page_id=page_id, title="TEST TITLE", properties=PROPERTY, cover=cover, icon=icon)
D.update_database(database_id=database_id, title="DB", add_properties=PROPERTY, cover=cover, icon=icon)
P.create_page(database_id=database_id, properties=PROPERTY, children=children, cover=cover, icon=icon)
P.update_page(page_id=page_id, properties=PROPERTY, cover=cover, icon=icon)
668168 commented 1 year ago

Wonderful 👍 👍 👍! the SET method works well, and there is 2 questions : First, Is there any GET mothod as get-properities? cover

Second, How can i choose the system emojis ? image

minwook-shin commented 1 year ago

@668168

  1. only feature to extract properties from dict of database.
D.retrieve_database(database_id, get_properties=True)
D.properties_list
  1. need to find and insert emoji specified in Unicode. (no plans to build-in emojis yet.)

ex) https://unicode.org/emoji/charts/full-emoji-list.html

668168 commented 1 year ago

Thank you, minwook,

For Question 1, Do you means neither the cover nor the icon can be extracted, and only the properties can be extracted?

For Question 2, Could you demonstrate how to insert an emoji specified in Unicode? The method shown below does not work. 😭

    # Update Page
    logger.debug("Update Page")
    icon = Icon()
    # icon.set_icon_image("😀")
    P.update_page(page_id=page_id, properties=PROPERTY, cover=cover, icon=icon)
minwook-shin commented 1 year ago

@668168 cover and icon has just been added and not support extraction yet. use in self.result (dict type)

and... Question 2 This works.

logger.debug("Update Page")
icon = Icon()
icon.set_icon_emoji("😀")
P.update_page(page_id=page_id, properties=PROPERTY, icon=icon)

If don't use cover, remove parameter as well.

668168 commented 1 year ago

@minwook-shin , Yes, It works!