Skip to content

Commit

Permalink
Merge pull request #1538 from Yessirskiy/master
Browse files Browse the repository at this point in the history
Slight docs update + new fbsearch method
  • Loading branch information
adw0rd committed Aug 15, 2023
2 parents 37d6165 + ecdbc29 commit a50fbda
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cl.video_upload_to_story(
* [`Collection`](https://adw0rd.github.io/instagrapi/usage-guide/collection.html) - Collection of medias (name, picture and list of medias)
* [`Comment`](https://adw0rd.github.io/instagrapi/usage-guide/comment.html) - Comments to Media
* [`Highlight`](https://adw0rd.github.io/instagrapi/usage-guide/highlight.html) - Highlights
* [`Notes`](https://adw0rd.github.io/instagrapi/usage-guide/notes.html)
* [`Notes`](https://adw0rd.github.io/instagrapi/usage-guide/notes.html) - Notes
* [`Story`](https://adw0rd.github.io/instagrapi/usage-guide/story.html) - Story
* [`StoryLink`](https://adw0rd.github.io/instagrapi/usage-guide/story.html) - Link Sticker
* [`StoryLocation`](https://adw0rd.github.io/instagrapi/usage-guide/story.html) - Tag Location in Story (as sticker)
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ To learn more about the various ways `instagrapi` can be used, read the [Usage G
* [`Collection`](usage-guide/collection.md) - Collection of medias (name, picture and list of medias)
* [`Comment`](usage-guide/comment.md) - Comments to Media
* [`Highlight`](usage-guide/highlight.md) - Highlights
* ['Notes'](usage-guide/notes.md) - Notes
* [`Story`](usage-guide/story.md) - Story
* [`StoryLink`](usage-guide/story.md) - Link (Swipe up)
* [`StoryLocation`](usage-guide/story.md) - Tag Location in Story (as sticker)
Expand Down
33 changes: 32 additions & 1 deletion instagrapi/mixins/fbsearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Dict, Tuple, Union

from instagrapi.extractors import (
extract_hashtag_v1,
Expand Down Expand Up @@ -73,3 +73,34 @@ def fbsearch_suggested_profiles(self, user_id: str) -> List[UserShort]:
}
result = self.private_request("fbsearch/accounts_recs/", params=params)
return result["users"]

def fbsearch_recent(self) -> List[Tuple[int, Union[UserShort, Hashtag, Dict]]]:
'''
Retrieves recently searched results
Returns
-------
List[Tuple[int, Union[UserShort, Hashtag, Dict]]]
Returns list of Tuples where first value is timestamp of searh, second is retrived result
'''
result = self.private_request("fbsearch/recent_searches/")
assert result.get("status", "") == "ok", "Failed to retrieve recent searches"

data = []
for item in result.get("recent", []):
if "user" in item.keys():
data.append((
item.get("client_time", None),
extract_user_short(item['user'])))
if "hashtag" in item.keys():
hashtag = item.get("hashtag")
hashtag["media_count"] = hashtag.pop("formatted_media_count")
data.append((
item.get("client_time", None),
Hashtag(**hashtag)))
if "keyword" in item.keys():
data.append((
item.get("client_time", None),
item["keyword"]
))
return data

0 comments on commit a50fbda

Please sign in to comment.