instapost 0.1.0__py3-none-any.whl → 0.2.0__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.
- instapost/client.py +28 -28
- instapost/posting/carousel.py +7 -7
- {instapost-0.1.0.dist-info → instapost-0.2.0.dist-info}/METADATA +2 -2
- {instapost-0.1.0.dist-info → instapost-0.2.0.dist-info}/RECORD +6 -6
- {instapost-0.1.0.dist-info → instapost-0.2.0.dist-info}/licenses/LICENSE +1 -1
- {instapost-0.1.0.dist-info → instapost-0.2.0.dist-info}/WHEEL +0 -0
instapost/client.py
CHANGED
|
@@ -26,52 +26,52 @@ class InstagramPoster(BaseInstagramClient):
|
|
|
26
26
|
raise NotImplementedError("Use post_image, post_reel, or post_carousel instead")
|
|
27
27
|
|
|
28
28
|
# Image methods
|
|
29
|
-
def upload_image(self,
|
|
29
|
+
def upload_image(self, image: str, caption: str = "") -> str:
|
|
30
30
|
"""Upload a single image and return container ID."""
|
|
31
|
-
return self._image.upload(
|
|
31
|
+
return self._image.upload(image, caption)
|
|
32
32
|
|
|
33
|
-
def post_image(self,
|
|
33
|
+
def post_image(self, image: str, caption: str = "") -> dict:
|
|
34
34
|
"""Upload and publish a single image.
|
|
35
35
|
|
|
36
36
|
Args:
|
|
37
|
-
|
|
37
|
+
image: URL or local file path to image
|
|
38
38
|
caption: Optional caption
|
|
39
39
|
|
|
40
40
|
Returns:
|
|
41
41
|
API response with published media ID
|
|
42
42
|
"""
|
|
43
43
|
# Auto-upload if local file
|
|
44
|
-
if os.path.exists(
|
|
45
|
-
|
|
44
|
+
if os.path.exists(image):
|
|
45
|
+
image = MediaUploader.upload_image(image)
|
|
46
46
|
|
|
47
|
-
return self._image.post(
|
|
47
|
+
return self._image.post(image, caption)
|
|
48
48
|
|
|
49
49
|
# Reel methods
|
|
50
50
|
def upload_reel(
|
|
51
51
|
self,
|
|
52
|
-
|
|
52
|
+
video: str,
|
|
53
53
|
caption: str = "",
|
|
54
|
-
|
|
54
|
+
cover: Optional[str] = None,
|
|
55
55
|
share_to_feed: bool = True,
|
|
56
56
|
timeout: int = 120,
|
|
57
57
|
) -> str:
|
|
58
58
|
"""Upload a reel and return container ID."""
|
|
59
|
-
return self._reel.upload(
|
|
59
|
+
return self._reel.upload(video, caption, cover, share_to_feed, timeout)
|
|
60
60
|
|
|
61
61
|
def post_reel(
|
|
62
62
|
self,
|
|
63
|
-
|
|
63
|
+
video: str,
|
|
64
64
|
caption: str = "",
|
|
65
|
-
|
|
65
|
+
cover: Optional[str] = None,
|
|
66
66
|
share_to_feed: bool = True,
|
|
67
67
|
timeout: int = 120,
|
|
68
68
|
) -> dict:
|
|
69
69
|
"""Upload and publish a reel.
|
|
70
70
|
|
|
71
71
|
Args:
|
|
72
|
-
|
|
72
|
+
video: URL or local file path to video
|
|
73
73
|
caption: Optional caption
|
|
74
|
-
|
|
74
|
+
cover: Optional URL or local path to cover image
|
|
75
75
|
share_to_feed: Whether to also share to feed
|
|
76
76
|
timeout: Video processing timeout in seconds
|
|
77
77
|
|
|
@@ -79,40 +79,40 @@ class InstagramPoster(BaseInstagramClient):
|
|
|
79
79
|
API response with published media ID
|
|
80
80
|
"""
|
|
81
81
|
# Auto-upload if local files
|
|
82
|
-
if os.path.exists(
|
|
83
|
-
|
|
82
|
+
if os.path.exists(video):
|
|
83
|
+
video = MediaUploader.upload_video(video)
|
|
84
84
|
|
|
85
|
-
if
|
|
86
|
-
|
|
85
|
+
if cover and os.path.exists(cover):
|
|
86
|
+
cover = MediaUploader.upload_image(cover)
|
|
87
87
|
|
|
88
|
-
return self._reel.post(
|
|
88
|
+
return self._reel.post(video, caption, cover, share_to_feed, timeout)
|
|
89
89
|
|
|
90
90
|
# Carousel methods
|
|
91
|
-
def upload_carousel(self,
|
|
91
|
+
def upload_carousel(self, media_items: list[dict], caption: str = "") -> str:
|
|
92
92
|
"""Upload a carousel and return container ID."""
|
|
93
|
-
return self._carousel.upload(
|
|
93
|
+
return self._carousel.upload(media_items, caption)
|
|
94
94
|
|
|
95
|
-
def post_carousel(self,
|
|
95
|
+
def post_carousel(self, media_items: list[dict], caption: str = "") -> dict:
|
|
96
96
|
"""Upload and publish a carousel.
|
|
97
97
|
|
|
98
98
|
Args:
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
media_items: List of dicts with 'media' (local file path or publicly accessible URL)
|
|
100
|
+
and 'type' keys. Type must be 'IMAGE' or 'VIDEO'
|
|
101
101
|
caption: Optional caption
|
|
102
102
|
|
|
103
103
|
Returns:
|
|
104
104
|
API response with published media ID
|
|
105
105
|
"""
|
|
106
106
|
# Auto-upload local files
|
|
107
|
-
|
|
108
|
-
for item in
|
|
107
|
+
processed_items = []
|
|
108
|
+
for item in media_items:
|
|
109
109
|
media = item['media']
|
|
110
110
|
if os.path.exists(media):
|
|
111
111
|
media = MediaUploader.upload(media)
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
processed_items.append({
|
|
114
114
|
'media': media,
|
|
115
115
|
'type': item['type']
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
-
return self._carousel.post(
|
|
118
|
+
return self._carousel.post(processed_items, caption)
|
instapost/posting/carousel.py
CHANGED
|
@@ -7,31 +7,31 @@ class CarouselPoster(BaseInstagramClient):
|
|
|
7
7
|
MIN_ITEMS = 2
|
|
8
8
|
MAX_ITEMS = 10
|
|
9
9
|
|
|
10
|
-
def upload(self,
|
|
10
|
+
def upload(self, media_items: list[dict], caption: str = "") -> str:
|
|
11
11
|
"""
|
|
12
12
|
Upload a carousel to Instagram.
|
|
13
13
|
|
|
14
14
|
Args:
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
media_items: List of dicts with 'media' (local file path or publicly accessible URL)
|
|
16
|
+
and 'type' ('IMAGE' or 'VIDEO') keys.
|
|
17
17
|
caption: Optional caption for the carousel.
|
|
18
18
|
|
|
19
19
|
Returns:
|
|
20
20
|
Container ID for publishing.
|
|
21
21
|
"""
|
|
22
|
-
if not self.MIN_ITEMS <= len(
|
|
22
|
+
if not self.MIN_ITEMS <= len(media_items) <= self.MAX_ITEMS:
|
|
23
23
|
raise ValueError(f"Carousel must have between {self.MIN_ITEMS} and {self.MAX_ITEMS} items")
|
|
24
24
|
|
|
25
|
-
children_ids = [self._create_child(media) for media in
|
|
25
|
+
children_ids = [self._create_child(media) for media in media_items]
|
|
26
26
|
return self._create_container({
|
|
27
27
|
"media_type": "CAROUSEL",
|
|
28
28
|
"children": ",".join(children_ids),
|
|
29
29
|
"caption": caption,
|
|
30
30
|
})
|
|
31
31
|
|
|
32
|
-
def post(self,
|
|
32
|
+
def post(self, media_items: list[dict], caption: str = "") -> dict:
|
|
33
33
|
"""Upload and publish a carousel."""
|
|
34
|
-
return self.publish(self.upload(
|
|
34
|
+
return self.publish(self.upload(media_items, caption))
|
|
35
35
|
|
|
36
36
|
def _create_child(self, media: dict) -> str:
|
|
37
37
|
"""Create a child container for a carousel item."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: instapost
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A Python library for automating Instagram posting (images, reels, carousels)
|
|
5
5
|
Project-URL: Homepage, https://blaya.ia.br
|
|
6
6
|
Project-URL: Repository, https://github.com/pedroluz/instapost
|
|
@@ -96,7 +96,7 @@ poster.post_reel(video="./video.mp4", caption="New reel! 🎬", share_to_feed=Tr
|
|
|
96
96
|
|
|
97
97
|
# Post a carousel
|
|
98
98
|
poster.post_carousel(
|
|
99
|
-
|
|
99
|
+
media_items=[
|
|
100
100
|
{"media": "./photo1.jpg", "type": "IMAGE"},
|
|
101
101
|
{"media": "./video.mp4", "type": "VIDEO"},
|
|
102
102
|
],
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
instapost/__init__.py,sha256=HhTIume5EvcD7jWTFnJmZee3h0dpramjur8501ccWLs,539
|
|
2
|
-
instapost/client.py,sha256=
|
|
2
|
+
instapost/client.py,sha256=M6K41MNDb0KGHGeJYtPrb-BAnXF92BoEEP6Cc7OVfgU,4099
|
|
3
3
|
instapost/exceptions.py,sha256=M7G5fXuLjDNoRnDSvyVqVXluHx8pxYn1VxtDX3qf3BU,347
|
|
4
4
|
instapost/api/__init__.py,sha256=6RVaMnFTtJm0l9nIC5tMBxJw7B_NFXxor7AlsqWb7hc,73
|
|
5
5
|
instapost/api/base.py,sha256=eNVUOqF_er1Kt6MMwdsk-FfO-3lUI0L-CcmPcDCy4Ko,2836
|
|
6
6
|
instapost/media/__init__.py,sha256=rhLMklySKJzeL1cCvhYfX4x-n23NAhgIzDXUT-0Aav0,65
|
|
7
7
|
instapost/media/uploader.py,sha256=cLbXUNau8EqtmnSj1xXOox4UuhHRnBo0fqlETWMcoMU,3384
|
|
8
8
|
instapost/posting/__init__.py,sha256=Jedqh7qWBfGtE9AoVPV8dWzZoNZ6xbZbejxbpmUU4lI,156
|
|
9
|
-
instapost/posting/carousel.py,sha256=
|
|
9
|
+
instapost/posting/carousel.py,sha256=2Rl_VQfKtW3s8HGsfsdNYtwpawOoWE8SUlQO5FwA3Ec,1789
|
|
10
10
|
instapost/posting/image.py,sha256=RH5VUyDkeiO6twRLklnLbvPkS_TJSxLG-Dl19oulHX8,721
|
|
11
11
|
instapost/posting/reel.py,sha256=-Uwbz2HoCmYzI-ZHJ97LPFMmmc4acnt0rRwgBH24RVU,1564
|
|
12
|
-
instapost-0.
|
|
13
|
-
instapost-0.
|
|
14
|
-
instapost-0.
|
|
15
|
-
instapost-0.
|
|
12
|
+
instapost-0.2.0.dist-info/METADATA,sha256=BkI4-cwMW4fH4w3SJ97FLfGTvD1GSMud1O2vb9lE7s0,4199
|
|
13
|
+
instapost-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
14
|
+
instapost-0.2.0.dist-info/licenses/LICENSE,sha256=dkJtwqp6h8qdcFKHbnKzGIMZx09yloEYxasC3rlSjP8,1071
|
|
15
|
+
instapost-0.2.0.dist-info/RECORD,,
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
|
File without changes
|