instapost 0.1.1__tar.gz → 0.2.0__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.
Files changed (28) hide show
  1. {instapost-0.1.1 → instapost-0.2.0}/PKG-INFO +2 -2
  2. {instapost-0.1.1 → instapost-0.2.0}/README.md +1 -1
  3. {instapost-0.1.1 → instapost-0.2.0}/instapost/client.py +28 -28
  4. {instapost-0.1.1 → instapost-0.2.0}/instapost/posting/carousel.py +7 -7
  5. {instapost-0.1.1 → instapost-0.2.0}/pyproject.toml +1 -1
  6. {instapost-0.1.1 → instapost-0.2.0}/tests/test_client.py +10 -10
  7. {instapost-0.1.1 → instapost-0.2.0}/tests/test_posting.py +8 -8
  8. {instapost-0.1.1 → instapost-0.2.0}/.github/workflows/publish-to-pypi.yml +0 -0
  9. {instapost-0.1.1 → instapost-0.2.0}/.github/workflows/python-package.yml +0 -0
  10. {instapost-0.1.1 → instapost-0.2.0}/.gitignore +0 -0
  11. {instapost-0.1.1 → instapost-0.2.0}/LICENSE +0 -0
  12. {instapost-0.1.1 → instapost-0.2.0}/MANIFEST.in +0 -0
  13. {instapost-0.1.1 → instapost-0.2.0}/instapost/__init__.py +0 -0
  14. {instapost-0.1.1 → instapost-0.2.0}/instapost/api/__init__.py +0 -0
  15. {instapost-0.1.1 → instapost-0.2.0}/instapost/api/base.py +0 -0
  16. {instapost-0.1.1 → instapost-0.2.0}/instapost/exceptions.py +0 -0
  17. {instapost-0.1.1 → instapost-0.2.0}/instapost/media/__init__.py +0 -0
  18. {instapost-0.1.1 → instapost-0.2.0}/instapost/media/uploader.py +0 -0
  19. {instapost-0.1.1 → instapost-0.2.0}/instapost/posting/__init__.py +0 -0
  20. {instapost-0.1.1 → instapost-0.2.0}/instapost/posting/image.py +0 -0
  21. {instapost-0.1.1 → instapost-0.2.0}/instapost/posting/reel.py +0 -0
  22. {instapost-0.1.1 → instapost-0.2.0}/logo.png +0 -0
  23. {instapost-0.1.1 → instapost-0.2.0}/requirements.txt +0 -0
  24. {instapost-0.1.1 → instapost-0.2.0}/tests/__init__.py +0 -0
  25. {instapost-0.1.1 → instapost-0.2.0}/tests/conftest.py +0 -0
  26. {instapost-0.1.1 → instapost-0.2.0}/tests/test_api.py +0 -0
  27. {instapost-0.1.1 → instapost-0.2.0}/tests/test_exceptions.py +0 -0
  28. {instapost-0.1.1 → instapost-0.2.0}/tests/test_media_uploader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instapost
3
- Version: 0.1.1
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
- media_urls=[
99
+ media_items=[
100
100
  {"media": "./photo1.jpg", "type": "IMAGE"},
101
101
  {"media": "./video.mp4", "type": "VIDEO"},
102
102
  ],
@@ -59,7 +59,7 @@ poster.post_reel(video="./video.mp4", caption="New reel! 🎬", share_to_feed=Tr
59
59
 
60
60
  # Post a carousel
61
61
  poster.post_carousel(
62
- media_urls=[
62
+ media_items=[
63
63
  {"media": "./photo1.jpg", "type": "IMAGE"},
64
64
  {"media": "./video.mp4", "type": "VIDEO"},
65
65
  ],
@@ -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, image_url: str, caption: str = "") -> str:
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(image_url, caption)
31
+ return self._image.upload(image, caption)
32
32
 
33
- def post_image(self, image_url: str, caption: str = "") -> dict:
33
+ def post_image(self, image: str, caption: str = "") -> dict:
34
34
  """Upload and publish a single image.
35
35
 
36
36
  Args:
37
- image_url: URL or local file path to image
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(image_url):
45
- image_url = MediaUploader.upload_image(image_url)
44
+ if os.path.exists(image):
45
+ image = MediaUploader.upload_image(image)
46
46
 
47
- return self._image.post(image_url, caption)
47
+ return self._image.post(image, caption)
48
48
 
49
49
  # Reel methods
50
50
  def upload_reel(
51
51
  self,
52
- video_url: str,
52
+ video: str,
53
53
  caption: str = "",
54
- cover_url: Optional[str] = None,
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(video_url, caption, cover_url, share_to_feed, timeout)
59
+ return self._reel.upload(video, caption, cover, share_to_feed, timeout)
60
60
 
61
61
  def post_reel(
62
62
  self,
63
- video_url: str,
63
+ video: str,
64
64
  caption: str = "",
65
- cover_url: Optional[str] = None,
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
- video_url: URL or local file path to video
72
+ video: URL or local file path to video
73
73
  caption: Optional caption
74
- cover_url: Optional URL or local path to cover image
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(video_url):
83
- video_url = MediaUploader.upload_video(video_url)
82
+ if os.path.exists(video):
83
+ video = MediaUploader.upload_video(video)
84
84
 
85
- if cover_url and os.path.exists(cover_url):
86
- cover_url = MediaUploader.upload_image(cover_url)
85
+ if cover and os.path.exists(cover):
86
+ cover = MediaUploader.upload_image(cover)
87
87
 
88
- return self._reel.post(video_url, caption, cover_url, share_to_feed, timeout)
88
+ return self._reel.post(video, caption, cover, share_to_feed, timeout)
89
89
 
90
90
  # Carousel methods
91
- def upload_carousel(self, media_urls: list[dict], caption: str = "") -> str:
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(media_urls, caption)
93
+ return self._carousel.upload(media_items, caption)
94
94
 
95
- def post_carousel(self, media_urls: list[dict], caption: str = "") -> dict:
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
- media_urls: List of dicts with 'media' (local file path or publicly accessible URL)
100
- and 'type' keys. Type must be 'IMAGE' or 'VIDEO'
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
- processed_urls = []
108
- for item in media_urls:
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
- processed_urls.append({
113
+ processed_items.append({
114
114
  'media': media,
115
115
  'type': item['type']
116
116
  })
117
117
 
118
- return self._carousel.post(processed_urls, caption)
118
+ return self._carousel.post(processed_items, caption)
@@ -7,31 +7,31 @@ class CarouselPoster(BaseInstagramClient):
7
7
  MIN_ITEMS = 2
8
8
  MAX_ITEMS = 10
9
9
 
10
- def upload(self, media_urls: list[dict], caption: str = "") -> str:
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
- media_urls: List of dicts with 'media' (local file path or publicly accessible URL)
16
- and 'type' ('IMAGE' or 'VIDEO') keys.
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(media_urls) <= self.MAX_ITEMS:
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 media_urls]
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, media_urls: list[dict], caption: str = "") -> dict:
32
+ def post(self, media_items: list[dict], caption: str = "") -> dict:
33
33
  """Upload and publish a carousel."""
34
- return self.publish(self.upload(media_urls, caption))
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."""
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "instapost"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  description = "A Python library for automating Instagram posting (images, reels, carousels)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -99,7 +99,7 @@ class TestInstagramPoster:
99
99
  with patch.object(client._reel, 'post', return_value={'media_id': 'post_cover'}):
100
100
  result = client.post_reel(
101
101
  temp_video_file,
102
- cover_url=temp_image_file,
102
+ cover=temp_image_file,
103
103
  share_to_feed=True,
104
104
  timeout=120
105
105
  )
@@ -114,7 +114,7 @@ class TestInstagramPoster:
114
114
  container_id = client.upload_reel(
115
115
  'https://example.com/video.mp4',
116
116
  caption='Test reel',
117
- cover_url='https://example.com/cover.jpg',
117
+ cover='https://example.com/cover.jpg',
118
118
  share_to_feed=False,
119
119
  timeout=60
120
120
  )
@@ -125,54 +125,54 @@ class TestInstagramPoster:
125
125
  def test_upload_carousel(self):
126
126
  """Test uploading a carousel."""
127
127
  client = InstagramPoster(access_token='token', ig_user_id='user')
128
- media_urls = [
128
+ media_items = [
129
129
  {'media': 'https://example.com/img1.jpg', 'type': 'IMAGE'},
130
130
  {'media': 'https://example.com/img2.jpg', 'type': 'IMAGE'},
131
131
  ]
132
132
 
133
133
  with patch.object(client._carousel, 'upload', return_value='carousel_123'):
134
- container_id = client.upload_carousel(media_urls)
134
+ container_id = client.upload_carousel(media_items)
135
135
 
136
136
  assert container_id == 'carousel_123'
137
137
 
138
138
  def test_post_carousel_urls(self):
139
139
  """Test posting a carousel from URLs."""
140
140
  client = InstagramPoster(access_token='token', ig_user_id='user')
141
- media_urls = [
141
+ media_items = [
142
142
  {'media': 'https://example.com/img1.jpg', 'type': 'IMAGE'},
143
143
  {'media': 'https://example.com/img2.jpg', 'type': 'IMAGE'},
144
144
  ]
145
145
 
146
146
  with patch.object(client._carousel, 'post', return_value={'media_id': 'carousel_post'}):
147
- result = client.post_carousel(media_urls)
147
+ result = client.post_carousel(media_items)
148
148
 
149
149
  assert result == {'media_id': 'carousel_post'}
150
150
 
151
151
  def test_post_carousel_local_files(self, temp_image_file):
152
152
  """Test posting a carousel with local files (auto-upload)."""
153
153
  client = InstagramPoster(access_token='token', ig_user_id='user')
154
- media_urls = [
154
+ media_items = [
155
155
  {'media': temp_image_file, 'type': 'IMAGE'},
156
156
  {'media': 'https://example.com/img2.jpg', 'type': 'IMAGE'},
157
157
  ]
158
158
 
159
159
  with patch('instapost.client.MediaUploader.upload', return_value='https://catbox.moe/img1.jpg'):
160
160
  with patch.object(client._carousel, 'post', return_value={'media_id': 'carousel_post_2'}):
161
- result = client.post_carousel(media_urls)
161
+ result = client.post_carousel(media_items)
162
162
 
163
163
  assert result == {'media_id': 'carousel_post_2'}
164
164
 
165
165
  def test_post_carousel_mixed_local_and_urls(self, temp_image_file):
166
166
  """Test posting carousel with mix of local files and URLs."""
167
167
  client = InstagramPoster(access_token='token', ig_user_id='user')
168
- media_urls = [
168
+ media_items = [
169
169
  {'media': temp_image_file, 'type': 'IMAGE'},
170
170
  {'media': 'https://example.com/video.mp4', 'type': 'VIDEO'},
171
171
  ]
172
172
 
173
173
  with patch('instapost.client.MediaUploader.upload', return_value='https://catbox.moe/uploaded.jpg'):
174
174
  with patch.object(client._carousel, 'post', return_value={'media_id': 'mixed_carousel'}):
175
- result = client.post_carousel(media_urls, caption='Mixed carousel')
175
+ result = client.post_carousel(media_items, caption='Mixed carousel')
176
176
 
177
177
  assert result == {'media_id': 'mixed_carousel'}
178
178
 
@@ -94,46 +94,46 @@ class TestCarouselPoster:
94
94
  def test_upload_carousel_valid(self):
95
95
  """Test uploading a valid carousel."""
96
96
  poster = CarouselPoster(access_token='token', ig_user_id='user')
97
- media_urls = [
97
+ media_items = [
98
98
  {'media': 'https://example.com/img1.jpg', 'type': 'IMAGE'},
99
99
  {'media': 'https://example.com/img2.jpg', 'type': 'IMAGE'},
100
100
  ]
101
101
 
102
102
  with patch.object(poster, '_create_child', side_effect=['child_1', 'child_2']):
103
103
  with patch.object(poster, '_create_container', return_value='carousel_123'):
104
- container_id = poster.upload(media_urls, caption='Carousel')
104
+ container_id = poster.upload(media_items, caption='Carousel')
105
105
 
106
106
  assert container_id == 'carousel_123'
107
107
 
108
108
  def test_upload_carousel_too_few_items(self):
109
109
  """Test carousel with too few items."""
110
110
  poster = CarouselPoster(access_token='token', ig_user_id='user')
111
- media_urls = [
111
+ media_items = [
112
112
  {'media': 'https://example.com/img1.jpg', 'type': 'IMAGE'},
113
113
  ]
114
114
 
115
115
  with pytest.raises(ValueError, match='between'):
116
- poster.upload(media_urls)
116
+ poster.upload(media_items)
117
117
 
118
118
  def test_upload_carousel_too_many_items(self):
119
119
  """Test carousel with too many items."""
120
120
  poster = CarouselPoster(access_token='token', ig_user_id='user')
121
- media_urls = [{'media': f'https://example.com/img{i}.jpg', 'type': 'IMAGE'} for i in range(12)]
121
+ media_items = [{'media': f'https://example.com/img{i}.jpg', 'type': 'IMAGE'} for i in range(12)]
122
122
 
123
123
  with pytest.raises(ValueError, match='between'):
124
- poster.upload(media_urls)
124
+ poster.upload(media_items)
125
125
 
126
126
  def test_upload_carousel_mixed_media(self):
127
127
  """Test carousel with mixed image and video."""
128
128
  poster = CarouselPoster(access_token='token', ig_user_id='user')
129
- media_urls = [
129
+ media_items = [
130
130
  {'media': 'https://example.com/img1.jpg', 'type': 'IMAGE'},
131
131
  {'media': 'https://example.com/video1.mp4', 'type': 'VIDEO'},
132
132
  ]
133
133
 
134
134
  with patch.object(poster, '_create_child', side_effect=['child_1', 'child_2']):
135
135
  with patch.object(poster, '_create_container', return_value='carousel_456'):
136
- container_id = poster.upload(media_urls)
136
+ container_id = poster.upload(media_items)
137
137
 
138
138
  assert container_id == 'carousel_456'
139
139
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes