python-substack 0.1.14__tar.gz → 0.1.15__tar.gz
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.
- {python_substack-0.1.14 → python_substack-0.1.15}/PKG-INFO +5 -1
- {python_substack-0.1.14 → python_substack-0.1.15}/README.md +4 -0
- {python_substack-0.1.14 → python_substack-0.1.15}/pyproject.toml +1 -1
- {python_substack-0.1.14 → python_substack-0.1.15}/substack/api.py +34 -1
- {python_substack-0.1.14 → python_substack-0.1.15}/substack/post.py +2 -0
- {python_substack-0.1.14 → python_substack-0.1.15}/LICENSE +0 -0
- {python_substack-0.1.14 → python_substack-0.1.15}/substack/__init__.py +0 -0
- {python_substack-0.1.14 → python_substack-0.1.15}/substack/exceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-substack
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.15
|
|
4
4
|
Summary: A Python wrapper around the Substack API.
|
|
5
5
|
Home-page: https://github.com/ma2za/python-substack
|
|
6
6
|
License: MIT
|
|
@@ -116,6 +116,10 @@ post.add({'type': 'captionedImage', 'src': "https://media.tenor.com/7B4jMa-a7bsA
|
|
|
116
116
|
image = api.get_image('image.png')
|
|
117
117
|
post.add({"type": "captionedImage", "src": image.get("url")})
|
|
118
118
|
|
|
119
|
+
# embed publication
|
|
120
|
+
embedded = api.publication_embed("https://jackio.substack.com/")
|
|
121
|
+
post.add({"type": "embeddedPublication", "url": embedded})
|
|
122
|
+
|
|
119
123
|
draft = api.post_draft(post.get_draft())
|
|
120
124
|
|
|
121
125
|
# set section (THIS CAN BE DONE ONLY AFTER HAVING FIRST POSTED THE DRAFT)
|
|
@@ -92,6 +92,10 @@ post.add({'type': 'captionedImage', 'src': "https://media.tenor.com/7B4jMa-a7bsA
|
|
|
92
92
|
image = api.get_image('image.png')
|
|
93
93
|
post.add({"type": "captionedImage", "src": image.get("url")})
|
|
94
94
|
|
|
95
|
+
# embed publication
|
|
96
|
+
embedded = api.publication_embed("https://jackio.substack.com/")
|
|
97
|
+
post.add({"type": "embeddedPublication", "url": embedded})
|
|
98
|
+
|
|
95
99
|
draft = api.post_draft(post.get_draft())
|
|
96
100
|
|
|
97
101
|
# set section (THIS CAN BE DONE ONLY AFTER HAVING FIRST POSTED THE DRAFT)
|
|
@@ -128,7 +128,11 @@ class Api:
|
|
|
128
128
|
response = self._session.get(
|
|
129
129
|
f"https://substack.com/sign-in?redirect=%2F&for_pub={publication['subdomain']}",
|
|
130
130
|
)
|
|
131
|
-
|
|
131
|
+
try:
|
|
132
|
+
output = Api._handle_response(response=response)
|
|
133
|
+
except SubstackRequestException as ex:
|
|
134
|
+
output = {}
|
|
135
|
+
return output
|
|
132
136
|
|
|
133
137
|
def change_publication(self, publication):
|
|
134
138
|
"""
|
|
@@ -538,3 +542,32 @@ class Api:
|
|
|
538
542
|
if p.get("hostname") in self.publication_url
|
|
539
543
|
]
|
|
540
544
|
return sections[0]
|
|
545
|
+
|
|
546
|
+
def publication_embed(self, url):
|
|
547
|
+
"""
|
|
548
|
+
|
|
549
|
+
Args:
|
|
550
|
+
url:
|
|
551
|
+
|
|
552
|
+
Returns:
|
|
553
|
+
|
|
554
|
+
"""
|
|
555
|
+
return self.call("/publication/embed", "GET", url=url)
|
|
556
|
+
|
|
557
|
+
def call(self, endpoint, method, **params):
|
|
558
|
+
"""
|
|
559
|
+
|
|
560
|
+
Args:
|
|
561
|
+
endpoint:
|
|
562
|
+
method:
|
|
563
|
+
**params:
|
|
564
|
+
|
|
565
|
+
Returns:
|
|
566
|
+
|
|
567
|
+
"""
|
|
568
|
+
response = self._session.request(
|
|
569
|
+
method=method,
|
|
570
|
+
url=f"{self.publication_url}/{endpoint}",
|
|
571
|
+
params=params,
|
|
572
|
+
)
|
|
573
|
+
return Api._handle_response(response=response)
|
|
@@ -84,6 +84,8 @@ class Post:
|
|
|
84
84
|
content = item.get("content")
|
|
85
85
|
if item.get("type") == "captionedImage":
|
|
86
86
|
self.captioned_image(**item)
|
|
87
|
+
elif item.get("type") == "embeddedPublication":
|
|
88
|
+
self.draft_body["content"][-1]["attrs"] = item.get("url")
|
|
87
89
|
elif item.get("type") == "youtube2":
|
|
88
90
|
self.youtube(item.get("src"))
|
|
89
91
|
elif item.get("type") == "subscribeWidget":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|