From 8c09d3f95206404fafbf529c04075e95abac901c Mon Sep 17 00:00:00 2001 From: KolyaDobrydnev Date: Tue, 15 Aug 2023 14:21:59 +0300 Subject: [PATCH 1/2] Note section in docs --- README.md | 2 +- docs/index.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 01e75737..9ab18447 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/index.md b/docs/index.md index 346e87a1..f6d3d2c2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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) From ecdbc298fa9cbc85fdfdbc9ee3b33c5c26407d10 Mon Sep 17 00:00:00 2001 From: KolyaDobrydnev Date: Tue, 15 Aug 2023 14:22:25 +0300 Subject: [PATCH 2/2] recent searches retrieve method --- instagrapi/mixins/fbsearch.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/instagrapi/mixins/fbsearch.py b/instagrapi/mixins/fbsearch.py index 2a5072dc..eecf823b 100644 --- a/instagrapi/mixins/fbsearch.py +++ b/instagrapi/mixins/fbsearch.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Dict, Tuple, Union from instagrapi.extractors import ( extract_hashtag_v1, @@ -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