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
- StoryMention , Usertag )
17
+ StoryLocation , StoryMention , Usertag )
18
18
from instagrapi .utils import dumps
19
19
20
20
try :
@@ -263,7 +263,7 @@ def photo_upload_to_story(
263
263
caption : str ,
264
264
upload_id : str = "" ,
265
265
mentions : List [StoryMention ] = [],
266
- location : Location = None ,
266
+ locations : List [ StoryLocation ] = [] ,
267
267
links : List [StoryLink ] = [],
268
268
hashtags : List [StoryHashtag ] = [],
269
269
) -> Story :
@@ -280,8 +280,8 @@ def photo_upload_to_story(
280
280
Unique upload_id (String). When None, then generate automatically. Example from video.video_configure
281
281
mentions: List[StoryMention], optional
282
282
List of mentions to be tagged on this upload, default is empty list.
283
- location: Location , optional
284
- Location tag for this upload, default is None
283
+ locations: List[StoryLocation] , optional
284
+ List of locations to be tagged on this upload, default is empty list.
285
285
links: List[StoryLink]
286
286
URLs for Swipe Up
287
287
hashtags: List[StoryHashtag], optional
@@ -303,7 +303,7 @@ def photo_upload_to_story(
303
303
height ,
304
304
caption ,
305
305
mentions ,
306
- location ,
306
+ locations ,
307
307
links ,
308
308
hashtags ,
309
309
):
@@ -313,6 +313,7 @@ def photo_upload_to_story(
313
313
links = links ,
314
314
mentions = mentions ,
315
315
hashtags = hashtags ,
316
+ locations = locations ,
316
317
** extract_media_v1 (media ).dict ()
317
318
)
318
319
raise PhotoConfigureStoryError (
@@ -326,7 +327,7 @@ def photo_configure_to_story(
326
327
height : int ,
327
328
caption : str ,
328
329
mentions : List [StoryMention ] = [],
329
- location : Location = None ,
330
+ locations : List [ StoryLocation ] = [] ,
330
331
links : List [StoryLink ] = [],
331
332
hashtags : List [StoryHashtag ] = [],
332
333
) -> Dict :
@@ -345,8 +346,8 @@ def photo_configure_to_story(
345
346
Media caption
346
347
mentions: List[StoryMention], optional
347
348
List of mentions to be tagged on this upload, default is empty list.
348
- location: Location , optional
349
- Location tag for this upload, default is None
349
+ locations: List[StoryLocation] , optional
350
+ List of locations to be tagged on this upload, default is empty list.
350
351
links: List[StoryLink]
351
352
URLs for Swipe Up
352
353
hashtags: List[StoryHashtag], optional
@@ -358,6 +359,7 @@ def photo_configure_to_story(
358
359
A dictionary of response from the call
359
360
"""
360
361
timestamp = int (time .time ())
362
+ story_sticker_ids = []
361
363
data = {
362
364
"text_metadata" : '[{"font_size":40.0,"scale":1.0,"width":611.0,"height":169.0,"x":0.51414347,"y":0.8487708,"rotation":0.0}]' ,
363
365
"supported_capabilities_new" : json .dumps (config .SUPPORTED_CAPABILITIES ),
@@ -366,7 +368,7 @@ def photo_configure_to_story(
366
368
"scene_capture_type" : "" ,
367
369
"timezone_offset" : "10800" ,
368
370
"client_shared_at" : str (timestamp - 5 ), # 5 seconds ago
369
- "story_sticker_ids" : "time_sticker_digital " ,
371
+ "story_sticker_ids" : "" ,
370
372
"media_folder" : "Camera" ,
371
373
"configure_mode" : "1" ,
372
374
"source_type" : "4" ,
@@ -378,21 +380,13 @@ def photo_configure_to_story(
378
380
"upload_id" : upload_id ,
379
381
"client_timestamp" : str (timestamp ),
380
382
"device" : self .device ,
381
- "implicit_location" : {},
382
383
"edits" : {
383
384
"crop_original_size" : [width * 1.0 , height * 1.0 ],
384
385
"crop_center" : [0.0 , 0.0 ],
385
386
"crop_zoom" : 1.0 ,
386
387
},
387
388
"extra" : {"source_width" : width , "source_height" : height },
388
389
}
389
- if location :
390
- assert isinstance (location , Location ), \
391
- f'location must been Location (not { type (location )} )'
392
- loc = self .location_build (location )
393
- data ["implicit_location" ] = {
394
- "media_location" : {"lat" : loc .lat , "lng" : loc .lng }
395
- }
396
390
if links :
397
391
links = [link .dict () for link in links ]
398
392
data ["story_cta" ] = dumps ([{"links" : links }])
@@ -416,6 +410,7 @@ def photo_configure_to_story(
416
410
data ["reel_mentions" ] = json .dumps (reel_mentions )
417
411
tap_models .extend (reel_mentions )
418
412
if hashtags :
413
+ story_sticker_ids .append ("hashtag_sticker" )
419
414
for mention in hashtags :
420
415
item = {
421
416
"x" : mention .x ,
@@ -431,7 +426,26 @@ def photo_configure_to_story(
431
426
"tap_state_str_id" : "hashtag_sticker_gradient"
432
427
}
433
428
tap_models .append (item )
429
+ if locations :
430
+ story_sticker_ids .append ("location_sticker" )
431
+ for mention in locations :
432
+ mention .location = self .location_complete (mention .location )
433
+ item = {
434
+ "x" : mention .x ,
435
+ "y" : mention .y ,
436
+ "z" : 0 ,
437
+ "width" : mention .width ,
438
+ "height" : mention .height ,
439
+ "rotation" : 0.0 ,
440
+ "type" : "location" ,
441
+ "location_id" : str (mention .location .pk ),
442
+ "is_sticker" : True ,
443
+ "tap_state" : 0 ,
444
+ "tap_state_str_id" : "location_sticker_vibrant"
445
+ }
446
+ tap_models .append (item )
434
447
data ["tap_models" ] = dumps (tap_models )
448
+ data ["story_sticker_ids" ] = dumps (story_sticker_ids )
435
449
return self .private_request (
436
450
"media/configure_to_story/" , self .with_default_data (data )
437
451
)
0 commit comments