14
14
PhotoConfigureStoryError , PhotoNotUpload )
15
15
from instagrapi .extractors import extract_media_v1
16
16
from instagrapi .types import (Location , Media , Story , StoryHashtag , StoryLink ,
17
- StoryLocation , StoryMention , Usertag )
17
+ StoryLocation , StoryMention , StorySticker , Usertag )
18
18
from instagrapi .utils import dumps
19
19
20
20
try :
@@ -266,6 +266,7 @@ def photo_upload_to_story(
266
266
locations : List [StoryLocation ] = [],
267
267
links : List [StoryLink ] = [],
268
268
hashtags : List [StoryHashtag ] = [],
269
+ stickers : List [StorySticker ] = [],
269
270
) -> Story :
270
271
"""
271
272
Upload photo as a story and configure it
@@ -286,6 +287,8 @@ def photo_upload_to_story(
286
287
URLs for Swipe Up
287
288
hashtags: List[StoryHashtag], optional
288
289
List of hashtags to be tagged on this upload, default is empty list.
290
+ stickers: List[StorySticker], optional
291
+ List of stickers to be tagged on this upload, default is empty list.
289
292
290
293
Returns
291
294
-------
@@ -306,6 +309,7 @@ def photo_upload_to_story(
306
309
locations ,
307
310
links ,
308
311
hashtags ,
312
+ stickers ,
309
313
):
310
314
media = self .last_json .get ("media" )
311
315
self .expose ()
@@ -314,6 +318,7 @@ def photo_upload_to_story(
314
318
mentions = mentions ,
315
319
hashtags = hashtags ,
316
320
locations = locations ,
321
+ stickers = stickers ,
317
322
** extract_media_v1 (media ).dict ()
318
323
)
319
324
raise PhotoConfigureStoryError (
@@ -330,6 +335,7 @@ def photo_configure_to_story(
330
335
locations : List [StoryLocation ] = [],
331
336
links : List [StoryLink ] = [],
332
337
hashtags : List [StoryHashtag ] = [],
338
+ stickers : List [StorySticker ] = [],
333
339
) -> Dict :
334
340
"""
335
341
Post configure photo
@@ -352,6 +358,8 @@ def photo_configure_to_story(
352
358
URLs for Swipe Up
353
359
hashtags: List[StoryHashtag], optional
354
360
List of hashtags to be tagged on this upload, default is empty list.
361
+ stickers: List[StorySticker], optional
362
+ List of stickers to be tagged on this upload, default is empty list.
355
363
356
364
Returns
357
365
-------
@@ -391,6 +399,7 @@ def photo_configure_to_story(
391
399
links = [link .dict () for link in links ]
392
400
data ["story_cta" ] = dumps ([{"links" : links }])
393
401
tap_models = []
402
+ static_models = []
394
403
if mentions :
395
404
reel_mentions = [
396
405
{
@@ -444,7 +453,24 @@ def photo_configure_to_story(
444
453
"tap_state_str_id" : "location_sticker_vibrant"
445
454
}
446
455
tap_models .append (item )
456
+ if stickers :
457
+ for sticker in stickers :
458
+ str_id = sticker .id # "gif_Igjf05J559JWuef4N5"
459
+ static_models .append ({
460
+ "x" : sticker .x ,
461
+ "y" : sticker .y ,
462
+ "z" : sticker .z ,
463
+ "width" : sticker .width ,
464
+ "height" : sticker .height ,
465
+ "rotation" : sticker .rotation ,
466
+ "str_id" : str_id ,
467
+ "sticker_type" : sticker .type ,
468
+ })
469
+ story_sticker_ids .append (str_id )
470
+ if sticker .type == "gif" :
471
+ data ["has_animated_sticker" ] = "1"
447
472
data ["tap_models" ] = dumps (tap_models )
473
+ data ["static_models" ] = dumps (static_models )
448
474
data ["story_sticker_ids" ] = dumps (story_sticker_ids )
449
475
return self .private_request (
450
476
"media/configure_to_story/" , self .with_default_data (data )
0 commit comments