notionary 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -379,10 +379,12 @@ class NotionDatabaseSchema:
379
379
  return
380
380
 
381
381
  for page in result["results"]:
382
- page_id = page.get("id", "")
382
+ page_id: str = page.get("id", "")
383
383
  title = self._extract_page_title(page)
384
+
385
+ page_url = f"https://notion.so/{page_id.replace('-', '')}"
384
386
 
385
- notion_page_manager = NotionPageManager(page_id=page_id, title=title)
387
+ notion_page_manager = NotionPageManager(page_id=page_id, title=title, url=page_url)
386
388
  yield notion_page_manager
387
389
 
388
390
  has_more = result.get("has_more", False)
@@ -1,3 +1,4 @@
1
+ import random
1
2
  from typing import Any, Dict, Optional
2
3
  from notionary.core.notion_client import NotionClient
3
4
  from notionary.util.logging_mixin import LoggingMixin
@@ -35,3 +36,23 @@ class MetadataEditor(LoggingMixin):
35
36
  f"pages/{self.page_id}",
36
37
  {"cover": {"type": "external", "external": {"url": external_url}}},
37
38
  )
39
+
40
+ async def set_random_gradient_cover(self) -> Optional[Dict[str, Any]]:
41
+ """
42
+ Sets a random gradient cover from Notion's default gradient covers.
43
+
44
+ Returns:
45
+ Optional[Dict[str, Any]]: The API response or None if the operation fails
46
+ """
47
+ default_notion_covers = [
48
+ "https://www.notion.so/images/page-cover/gradients_8.png",
49
+ "https://www.notion.so/images/page-cover/gradients_2.png",
50
+ "https://www.notion.so/images/page-cover/gradients_11.jpg",
51
+ "https://www.notion.so/images/page-cover/gradients_10.jpg",
52
+ "https://www.notion.so/images/page-cover/gradients_5.png",
53
+ "https://www.notion.so/images/page-cover/gradients_3.png"
54
+ ]
55
+
56
+ random_cover_url = random.choice(default_notion_covers)
57
+
58
+ return await self.set_cover(random_cover_url)
@@ -105,10 +105,21 @@ class NotionPageManager(LoggingMixin):
105
105
  self, emoji: Optional[str] = None, external_url: Optional[str] = None
106
106
  ) -> Optional[Dict[str, Any]]:
107
107
  return await self._metadata.set_icon(emoji, external_url)
108
+
109
+ async def get_cover_url(self) -> str:
110
+ page_data = await self._client.get_page(self._page_id)
111
+
112
+ if not page_data:
113
+ return ""
114
+
115
+ return page_data.get("cover", {}).get("external", {}).get("url", "")
108
116
 
109
117
  async def set_page_cover(self, external_url: str) -> Optional[Dict[str, Any]]:
110
118
  return await self._metadata.set_cover(external_url)
111
119
 
120
+ async def set_random_gradient_cover(self) -> Optional[Dict[str, Any]]:
121
+ return await self._metadata.set_random_gradient_cover()
122
+
112
123
  async def get_properties(self) -> Dict[str, Any]:
113
124
  """Retrieves all properties of the page"""
114
125
  page_data = await self._client.get_page(self._page_id)
@@ -126,4 +137,15 @@ class NotionPageManager(LoggingMixin):
126
137
  properties = await self.get_properties()
127
138
  if "Status" in properties and properties["Status"].get("status"):
128
139
  return properties["Status"]["status"]["name"]
129
- return None
140
+ return None
141
+
142
+
143
+ async def main():
144
+ page_manager = NotionPageManager(page_id="https://notion.so/1d0389d57bd3805cb34ccaf5804b43ce")
145
+ cover_url = await page_manager.get_cover_url()
146
+ print(f"Cover URL: {cover_url}")
147
+
148
+
149
+ if __name__ == "__main__":
150
+ import asyncio
151
+ asyncio.run(main())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -26,21 +26,21 @@ notionary/core/database/database_query_service.py,sha256=ggD-Sx9GdRTeKn9ytGBxijQ
26
26
  notionary/core/database/database_schema_service.py,sha256=aVyguzw8YjgQ632TDyRCDfWWCsIok3vJ4Sx3dnG9pss,1869
27
27
  notionary/core/database/notion_database_manager.py,sha256=E3qUxPYEJ1drurmtZaqepskH84Iw-4RN3MyXv8cb8zQ,11443
28
28
  notionary/core/database/notion_database_manager_factory.py,sha256=jYQeoWV4VKyfCkbxCMVf0aeShfXDvE2EVTs3Jr--Ro8,8285
29
- notionary/core/database/notion_database_schema.py,sha256=DpZPkrR15u24PGd8jhTrqngu__5LviEsU-VBZgRzrHM,12486
29
+ notionary/core/database/notion_database_schema.py,sha256=OtAsKzga7eiWzUa4AasNO2MBOTlQERQ_9Gk22Kc6f64,12599
30
30
  notionary/core/database/notion_database_writer.py,sha256=qpKOSDLI89GWL1kDnzLKSY5GVIzQHVYAWUl12_n-nwU,13651
31
31
  notionary/core/database/page_service.py,sha256=NzKCU2G-mnmqOitNWCJ6jOr0HSv1vPi1-ScSruvFdqg,5190
32
32
  notionary/core/database/models/page_result.py,sha256=Vmm5_oYpYAkIIJVoTd1ZZGloeC3cmFLMYP255mAmtaw,233
33
- notionary/core/page/notion_page_manager.py,sha256=fvEomwMMOkjUBnE6QdTfrzfNsqTTuVi-7a9ehC3U29Q,4865
33
+ notionary/core/page/notion_page_manager.py,sha256=wNkxm4kMd6hogdrNKbHQz16EE8D5wdLy5cPIuvTypG8,5582
34
34
  notionary/core/page/page_content_manager.py,sha256=wx-2bW4znIaBVZeFwtoVrmlGUwHMLBPOLkQCZDIV3sA,3180
35
35
  notionary/core/page/property_formatter.py,sha256=X70Yfg0Y8HYLrFH7Y_BZVhhc_6b369jjn02bc5IZBBI,3780
36
- notionary/core/page/meta_data/metadata_editor.py,sha256=FpB7BA5cicWmEictwdn7EuRBMX7bGvSxbdM5Grs-jLI,1347
36
+ notionary/core/page/meta_data/metadata_editor.py,sha256=6v1qiTpQMWlJv5YSYiDwakllSgbOsy9mlC3jNC5BImk,2286
37
37
  notionary/exceptions/database_exceptions.py,sha256=I-Tx6bYRLpi5pjGPtbT-Mqxvz3BFgYTiuZxknJeLxtI,2638
38
38
  notionary/exceptions/page_creation_exception.py,sha256=4v7IuZD6GsQLrqhDLriGjuG3ML638gAO53zDCrLePuU,281
39
39
  notionary/util/logging_mixin.py,sha256=fKsx9t90bwvL74ZX3dU-sXdC4TZCQyO6qU9I8txkw_U,1369
40
40
  notionary/util/singleton_decorator.py,sha256=GTNMfIlVNRUVMw_c88xqd12-DcqZJjmyidN54yqiNVw,472
41
41
  notionary/util/uuid_utils.py,sha256=qS2tdJSqw_gLyQxVIqlIdmkzGa7b9bJ-vw88RiQ-oGc,680
42
- notionary-0.1.4.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
43
- notionary-0.1.4.dist-info/METADATA,sha256=xcQjDgdfcTJ7T5ThHVPanYDcfYIMeNKo841a1_Ijs14,6153
44
- notionary-0.1.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
45
- notionary-0.1.4.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
46
- notionary-0.1.4.dist-info/RECORD,,
42
+ notionary-0.1.6.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
43
+ notionary-0.1.6.dist-info/METADATA,sha256=ktC2Qs9nn2MYfiWQLt9YP_5verBw8_dPHxkxYy0Fbbc,6153
44
+ notionary-0.1.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
45
+ notionary-0.1.6.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
46
+ notionary-0.1.6.dist-info/RECORD,,