Skip to content

Commit

Permalink
Merge pull request #1535 from rickturner2001/master
Browse files Browse the repository at this point in the history
Refactor: inconsistent type annotation for user_id
  • Loading branch information
adw0rd authored Aug 13, 2023
2 parents 28b2300 + adbb2be commit 37d6165
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 92 deletions.
2 changes: 1 addition & 1 deletion docs/usage-guide/highlight.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| ------------------------------------------------------------------------------ | ---------------- | ----------------------------------
| highlight_pk_from_url(url: str) | int | Get Highlight PK from URL
| highlight_info(highlight_pk: int) | Highlight | Get Highlight by pk or id
| user_highlights(user_id: int, amount: int = 0) | List[Highlight] | Get a user's highlights
| user_highlights(user_id: str, amount: int = 0) | List[Highlight] | Get a user's highlights
| highlight_create(title: str, story_ids: List[str], cover_story_id: str = "", crop_rect: List[float] = [0.0, 0.21830457, 1.0, 0.78094524]) | Highlight | Create highlight
| highlight_change_title(highlight_pk: str, title: str) | Highlight | Change title for highlight
| highlight_change_cover(highlight_pk: str, cover_path: Path) | Highlight | Change cover for highlight
Expand Down
26 changes: 13 additions & 13 deletions docs/usage-guide/media.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ In terms of Instagram, this is called Media, usually users call it publications
| media_pk(media_id: str) | int | Return media_pk by media_id (e.g. 2277033926878261772_1903424587 -> 2277033926878261772)
| media_pk_from_code(code: str) | int | Return media_pk
| media_pk_from_url(url: str) | int | Return media_pk
| user_medias(user_id: int, amount: int = 20) | List\[Media] | Get list of medias by user_id
| user_medias_paginated(user_id: int, amount: int = 0, end_cursor: str = "") | Tuple\[List\[Media], str] | Get one page of medias by user_id
| user_clips(user_id: int, amount: int = 50) | List\[Media] | Get list of clips (reels) by user_id
| usertag_medias(user_id: int, amount: int = 20) | List\[Media] | Get medias where a user is tagged
| user_medias(user_id: str, amount: int = 20) | List\[Media] | Get list of medias by user_id
| user_medias_paginated(user_id: str, amount: int = 0, end_cursor: str = "") | Tuple\[List\[Media], str] | Get one page of medias by user_id
| user_clips(user_id: str, amount: int = 50) | List\[Media] | Get list of clips (reels) by user_id
| usertag_medias(user_id: str, amount: int = 20) | List\[Media] | Get medias where a user is tagged
| media_info(media_pk: int) | Media | Return media info
| media_delete(media_pk: int) | bool | Delete media
| media_edit(media_pk: int, caption: str, title: str, usertags: List[Usertag], location: Location) | dict | Change caption for media
Expand All @@ -52,16 +52,16 @@ Low level methods:
| media_info_a1(media_pk: int, max_id: str = None) | Media | Get Media from PK by Public Web API
| media_info_gql(media_pk: int) | Media | Get Media from PK by Public Graphql API
| media_info_v1(media_pk: int) | Media | Get Media from PK by Private Mobile API
| user_medias_gql(user_id: int, amount: int = 50, sleep: int = 2) | List\[Media] | Get a user's media by Public Graphql API
| user_medias_paginated_gql(user_id: int, amount: int = 50, sleep: int = 2, end_cursor=None) | Tuple\[List\[Media], str] | Get a page of user's media by Public Graphql API
| user_medias_v1(user_id: int, amount: int = 18) | List\[Media] | Get a user's media by Private Mobile API
| user_medias_paginated_v1(user_id: int, amount: int = 0, end_cursor="") | Tuple\[List\[Media], str] | Get a page of user's media by Private Mobile API
| user_clips_v1(user_id: int, amount: int = 50) | List\[Media] | Get a user's clip by Private Mobile API
| user_clips_paginated_v1(user_id: int, amount: int = 50, end_cursor="") | Tuple\[List\[Media], str] | Get a page of user's clip by Private Mobile API
| user_videos_v1(user_id: int, amount: int = 50) | List\[Media] | Get a user's video by Private Mobile API
| user_medias_gql(user_id: str, amount: int = 50, sleep: int = 2) | List\[Media] | Get a user's media by Public Graphql API
| user_medias_paginated_gql(user_id: str, amount: int = 50, sleep: int = 2, end_cursor=None) | Tuple\[List\[Media], str] | Get a page of user's media by Public Graphql API
| user_medias_v1(user_id: str, amount: int = 18) | List\[Media] | Get a user's media by Private Mobile API
| user_medias_paginated_v1(user_id: str, amount: int = 0, end_cursor="") | Tuple\[List\[Media], str] | Get a page of user's media by Private Mobile API
| user_clips_v1(user_id: str, amount: int = 50) | List\[Media] | Get a user's clip by Private Mobile API
| user_clips_paginated_v1(user_id: str, amount: int = 50, end_cursor="") | Tuple\[List\[Media], str] | Get a page of user's clip by Private Mobile API
| user_videos_v1(user_id: str, amount: int = 50) | List\[Media] | Get a user's video by Private Mobile API
| user_videos_paginated_v1(ser_id: int, amount: int = 50, end_cursor="") | Tuple\[List\[Media], str] | Get a page of user's video by Private Mobile API
| usertag_medias_gql(user_id: int, amount: int = 20) | List\[Media] | Get medias where a user is tagged by Public Graphql API
| usertag_medias_v1(user_id: int, amount: int = 20) | List\[Media] | Get medias where a user is tagged by Private Mobile API
| usertag_medias_gql(user_id: str, amount: int = 20) | List\[Media] | Get medias where a user is tagged by Public Graphql API
| usertag_medias_v1(user_id: str, amount: int = 20) | List\[Media] | Get medias where a user is tagged by Private Mobile API

### Example:

Expand Down
2 changes: 1 addition & 1 deletion docs/usage-guide/story.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Method | Return | Description
| ---------------------------------------------------------------------- | --------------- | ----------------------------------
| user_stories(user_id: int, amount: int = None) | List[Story] | Get list of stories by user_id
| user_stories(user_id: str, amount: int = None) | List[Story] | Get list of stories by user_id
| story_info(story_pk: int, use_cache: bool = True) | Story | Return story info
| story_delete(story_pk: int) | bool | Delete story
| story_seen(story_pks: List[int], skipped_story_pks: List[int]) | bool | Mark a story as seen
Expand Down
60 changes: 30 additions & 30 deletions docs/usage-guide/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ View a list of a user's medias, following and followers

| Method | Return | Description |
|-----------------------------------------------|-----------------------|--------------------------------------------------------------|
| user_followers(user_id: int, amount: int = 0) | Dict\[int, UserShort] | Get dict of followers users (amount=0 - fetch all followers) |
| user_following(user_id: int, amount: int = 0) | Dict\[int, UserShort] | Get dict of following users (amount=0 - fetch all) |
| search_followers(user_id: int, query: str) | List[UserShort] | Search by followers |
| search_following(user_id: int, query: str) | List[UserShort] | Search by following |
| user_info(user_id: int) | User | Get user info |
| user_followers(user_id: str, amount: int = 0) | Dict\[int, UserShort] | Get dict of followers users (amount=0 - fetch all followers) |
| user_following(user_id: str, amount: int = 0) | Dict\[int, UserShort] | Get dict of following users (amount=0 - fetch all) |
| search_followers(user_id: str, query: str) | List[UserShort] | Search by followers |
| search_following(user_id: str, query: str) | List[UserShort] | Search by following |
| user_info(user_id: str) | User | Get user info |
| user_info_by_username(username: str) | User | Get user info by username |
| user_follow(user_id: int) | bool | Follow user |
| user_unfollow(user_id: int) | bool | Unfollow user |
| user_follow(user_id: str) | bool | Follow user |
| user_unfollow(user_id: str) | bool | Unfollow user |
| user_id_from_username(username: str) | int | Get user_id by username |
| username_from_user_id(user_id: int) | str | Get username by user_id |
| user_remove_follower(user_id: int) | bool | Remove your follower |
| mute_posts_from_follow(user_id: int) | bool | Mute posts from following user |
| unmute_posts_from_follow(user_id: int) | bool | Unmute posts from following user |
| mute_stories_from_follow(user_id: int) | bool | Mute stories from following user |
| enable_posts_notifications(user_id: int) | bool | Enable post notifications of user |
| disable_posts_notifications(user_id: int) | bool | Disable post notifications of user |
| enable_videos_notifications(user_id: int) | bool | Enable videos notifications of user |
| disable_videos_notifications(user_id: int) | bool | Disable videos notifications of user |
| enable_reels_notifications(user_id: int) | bool | Enable reels notifications of user |
| disable_reels_notifications(user_id: int) | bool | Disable reels notifications of user |
| enable_stories_notifications(user_id: int) | bool | Enable stories notifications of user |
| disable_stories_notifications(user_id: int) | bool | Disable stories notifications of user |
| close_friend_add(user_id: int) | bool | Add to Close Friends List |
| close_friend_remove(user_id: int) | bool | Remove from Close Friends List |
| username_from_user_id(user_id: str) | str | Get username by user_id |
| user_remove_follower(user_id: str) | bool | Remove your follower |
| mute_posts_from_follow(user_id: str) | bool | Mute posts from following user |
| unmute_posts_from_follow(user_id: str) | bool | Unmute posts from following user |
| mute_stories_from_follow(user_id: str) | bool | Mute stories from following user |
| enable_posts_notifications(user_id: str) | bool | Enable post notifications of user |
| disable_posts_notifications(user_id: str) | bool | Disable post notifications of user |
| enable_videos_notifications(user_id: str) | bool | Enable videos notifications of user |
| disable_videos_notifications(user_id: str) | bool | Disable videos notifications of user |
| enable_reels_notifications(user_id: str) | bool | Enable reels notifications of user |
| disable_reels_notifications(user_id: str) | bool | Disable reels notifications of user |
| enable_stories_notifications(user_id: str) | bool | Enable stories notifications of user |
| disable_stories_notifications(user_id: str) | bool | Disable stories notifications of user |
| close_friend_add(user_id: str) | bool | Add to Close Friends List |
| close_friend_remove(user_id: str) | bool | Remove from Close Friends List |

Low level methods:

| Method | Return | Description |
|-------------------------------------------------------------------------------------|-----------------------------|----------------------------------------------------------------------------|
| user_followers_gql_chunk(user_id: int, max_amount: int = 0, end_cursor: str = None) | Tuple[List[UserShort], str] | Get user's followers information by Public Graphql API and end_cursor |
| user_followers_gql(user_id: int, amount: int = 0) | List[UserShort] | Get user's followers information by Public Graphql API |
| user_followers_v1_chunk(user_id: int, max_amount: int = 0, max_id: str = "") | Tuple[List[UserShort], str] | Get user's followers information by Private Mobile API and max_id (cursor) |
| user_followers_v1(user_id: int, amount: int = 0) | List[UserShort] | Get user's followers information by Private Mobile API |
| user_following_v1(user_id: int, amount: int = 0) | List[UserShort] | Get user's following users information by Private Mobile API |
| user_following_gql(user_id: int, amount: int = 0) | List[UserShort] | Get user's following information by Public Graphql API |
| search_followers_v1(user_id: int, query: str) | List[UserShort] | Search by followers by Private Mobile API |
| search_following_v1(user_id: int, query: str) | List[UserShort] | Search by following by Private Mobile API |
| user_followers_gql_chunk(user_id: str, max_amount: int = 0, end_cursor: str = None) | Tuple[List[UserShort], str] | Get user's followers information by Public Graphql API and end_cursor |
| user_followers_gql(user_id: str, amount: int = 0) | List[UserShort] | Get user's followers information by Public Graphql API |
| user_followers_v1_chunk(user_id: str, max_amount: int = 0, max_id: str = "") | Tuple[List[UserShort], str] | Get user's followers information by Private Mobile API and max_id (cursor) |
| user_followers_v1(user_id: str, amount: int = 0) | List[UserShort] | Get user's followers information by Private Mobile API |
| user_following_v1(user_id: str, amount: int = 0) | List[UserShort] | Get user's following users information by Private Mobile API |
| user_following_gql(user_id: str, amount: int = 0) | List[UserShort] | Get user's following information by Public Graphql API |
| search_followers_v1(user_id: str, query: str) | List[UserShort] | Search by followers by Private Mobile API |
| search_following_v1(user_id: str, query: str) | List[UserShort] | Search by following by Private Mobile API |

Example:

Expand Down
6 changes: 3 additions & 3 deletions instagrapi/mixins/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def get_reels_tray_feed(
if reason == "cold_start":
data["reel_tray_impressions"] = {}
else:
data["reel_tray_impressions"] = {self.user_id: int(time.time())}
data["reel_tray_impressions"] = {self.user_id: str(time.time())}
return self.private_request("feed/reels_tray/", data)


Expand Down Expand Up @@ -474,12 +474,12 @@ def login(
return True
return False

def one_tap_app_login(self, user_id: int, nonce: str) -> bool:
def one_tap_app_login(self, user_id: str, nonce: str) -> bool:
"""One tap login emulation
Parameters
----------
user_id: int
user_id: str
User ID
nonce: str
Login nonce (from Instagram, e.g. in /logout/)
Expand Down
2 changes: 1 addition & 1 deletion instagrapi/mixins/fundraiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class FundraiserMixin:
Helpers for the fundraisers.
"""

def standalone_fundraiser_info_v1(self, user_id: int):
def standalone_fundraiser_info_v1(self, user_id: str):
"""
Get fundraiser info.
Expand Down
8 changes: 4 additions & 4 deletions instagrapi/mixins/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def highlight_pk_from_url(self, url: str) -> str:
parts = [p for p in path.split("/") if p and p.isdigit()]
return str(parts[0])

def user_highlights_v1(self, user_id: int, amount: int = 0) -> List[Highlight]:
def user_highlights_v1(self, user_id: str, amount: int = 0) -> List[Highlight]:
"""
Get a user's highlight
Parameters
----------
user_id: int
user_id: str
amount: int, optional
Maximum number of highlight to return, default is 0 (all highlights)
Expand All @@ -67,13 +67,13 @@ def user_highlights_v1(self, user_id: int, amount: int = 0) -> List[Highlight]:
)
return [extract_highlight_v1(highlight) for highlight in result.get("tray", [])]

def user_highlights(self, user_id: int, amount: int = 0) -> List[Highlight]:
def user_highlights(self, user_id: str, amount: int = 0) -> List[Highlight]:
"""
Get a user's highlights
Parameters
----------
user_id: int
user_id: str
amount: int, optional
Maximum number of highlight to return, default is 0 (all highlights)
Expand Down
Loading

0 comments on commit 37d6165

Please sign in to comment.