instagrapi icon indicating copy to clipboard operation
instagrapi copied to clipboard

Stories Url

Open EndlessM0DZ opened this issue 3 years ago • 5 comments

Urls on stories dont populate in the api. I believe it is because the json response changed from url to needing to access it through story stickers. I think this json response changed since instagram got rid of the url slide ups and gave everyone access to url stickers. I tried to change the api myself and it worked but only when all the users stories have a url sticker. When there is a story that doesnt have the story_link_stickers it is not included in the json response for that item and throws this error: 1 validation error for Story story_link_stickers value is not a valid dict (type=type_error.dict)

I really appreciate your api :)

This is the edited code for reference:

class StoryLink(BaseModel): link_type: str url: str link_title: str display_url: str

class StorySticker(BaseModel): x: float y: float width: float height: float story_link: Optional[StoryLink]

class Story(BaseModel): pk: str id: str code: str taken_at: datetime media_type: int product_type: Optional[str] = "" thumbnail_url: Optional[HttpUrl] user: UserShort video_url: Optional[HttpUrl] # for Video and IGTV video_duration: Optional[float] = 0.0 # for Video and IGTV mentions: List[StoryMention] links: List[StoryLink] hashtags: List[StoryHashtag] locations: List[StoryLocation] story_link_stickers: List[StorySticker] medias: List[StoryMedia] = []

EndlessM0DZ avatar Mar 07 '22 07:03 EndlessM0DZ

Hi @EndlessM0DZ . I have issue that story_link_stickers is not exist in response, but when I opening stories I can see sticker and in chrome console I can see story_link_stickers by https://i.instagram.com/api/v1/feed/reels_media/?reel_ids=12058438235 (12058438235 is user pk). Example of response here

endemio avatar Mar 08 '22 01:03 endemio

@endemio yeah I have that issue too its not in existence in response when the story doesnt have a link on it. I added story_link_stickers in the types file on my local pc after looking at the response to get the link from stories, but I get that error mentioned above. I tried using Optional[] in pydantic so it doesnt throw error, but it always always shows up as None even when it has a link. Somehow I need to make pydantic accept the class with story_link_stickers and set it to something only if it doesnt have it in the response but Im unsure how to do that

EndlessM0DZ avatar Mar 08 '22 01:03 EndlessM0DZ

@EndlessM0DZ I haven't story_link_stickers in json even if it exist in story, thats why I wondering why you need it if IG doesn't senfing this data

endemio avatar Mar 11 '22 19:03 endemio

in extract_story_v1 function i changed: story["sticker"] = [] to --> story["stickers"] = data.get('story_link_stickers') or []

now it returns the stickers with the urls

hope it helps

yonimar avatar Jul 23 '22 06:07 yonimar

@yonimar thanks, added this to the repo

adw0rd avatar Jul 23 '22 10:07 adw0rd