Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding possibility to retrieve all links in bio and is_paid_partnership flag for story #1793

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -414,6 +414,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 @@ -244,6 +255,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 @@ -295,13 +307,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
Loading