Skip to content

Commit

Permalink
Merge pull request #1793 from DZeitounPEReN/extract_story
Browse files Browse the repository at this point in the history
adding possibility to retrieve all links in bio and is_paid_partnership flag for story
  • Loading branch information
subzeroid authored Feb 27, 2024
2 parents ab33861 + 2d18e43 commit 3695daa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions instagrapi/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
Resource,
Story,
StoryLink,
StoryMedia,
StoryMention,
StoryLocation,
StoryHashtag,
StoryMedia,
StoryMention,
Track,
User,
UserShort,
Expand Down Expand Up @@ -418,6 +418,7 @@ def extract_story_v1(data):
story["links"].append(StoryLink(**link))
story["user"] = extract_user_short(story.get("user"))
story["sponsor_tags"] = [tag["sponsor"] for tag in story.get("sponsor_tags", [])]
story["is_paid_partnership"] = story.get("is_paid_partnership")
return Story(**story)


Expand Down
14 changes: 14 additions & 0 deletions instagrapi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class Resource(TypesBaseModel):
media_type: int


class BioLink(TypesBaseModel):
link_id: str
url: str
lynx_url: Optional[str] = None
link_type: Optional[str] = None
title: Optional[str] = None
is_pinned: Optional[bool] = None
open_external_url_with_in_app_browser: Optional[bool] = None


class User(TypesBaseModel):
pk: str
username: str
Expand All @@ -42,6 +52,7 @@ class User(TypesBaseModel):
follower_count: int
following_count: int
biography: Optional[str] = ""
bio_links: List[BioLink] = []
external_url: Optional[str] = None
account_type: Optional[int] = None
is_business: bool
Expand Down Expand Up @@ -250,6 +261,7 @@ class StoryHashtag(TypesBaseModel):
height: Optional[float] = None
rotation: Optional[float] = None


class StoryLocation(TypesBaseModel):
location: Location
x: Optional[float] = None
Expand Down Expand Up @@ -301,13 +313,15 @@ class Story(TypesBaseModel):
id: str
code: str
taken_at: datetime
imported_taken_at: Optional[datetime] = None
media_type: int
product_type: Optional[str] = ""
thumbnail_url: Optional[HttpUrl] = None
user: UserShort
video_url: Optional[HttpUrl] = None # for Video and IGTV
video_duration: Optional[float] = 0.0 # for Video and IGTV
sponsor_tags: List[UserShort]
is_paid_partnership: Optional[bool]
mentions: List[StoryMention]
links: List[StoryLink]
hashtags: List[StoryHashtag]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

setup(
name="instagrapi",
version="2.0.4",
version="2.1.0",
author="Mark Subzeroid",
author_email="[email protected]",
license="MIT",
Expand Down

0 comments on commit 3695daa

Please sign in to comment.