From 0bc91b722ede6643a2819fcc94ccfe34989622f4 Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Fri, 24 Jan 2025 08:16:43 +0100 Subject: [PATCH] Fix download hashtags Closes #2144. --- docs/basic-usage.rst | 2 +- instaloader/instaloader.py | 1 + instaloader/structures.py | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/basic-usage.rst b/docs/basic-usage.rst index 7eac56d..5c154ba 100644 --- a/docs/basic-usage.rst +++ b/docs/basic-usage.rst @@ -99,7 +99,7 @@ Instaloader supports the following targets: to **download IGTV videos**. - ``"#hashtag"`` - Posts with a certain **hashtag** (the quotes are usually necessary). + Posts with a certain **hashtag** (the quotes are usually necessary). Requires :ref:`login`. - ``%location id`` Posts tagged with a given location; the location ID is the numerical ID diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 4abcac0..fc32af4 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -1215,6 +1215,7 @@ class Instaloader: Use :meth:`Hashtag.get_posts_resumable`.""" return Hashtag.from_name(self.context, hashtag).get_posts_resumable() + @_requires_login def download_hashtag(self, hashtag: Union[Hashtag, str], max_count: Optional[int] = None, post_filter: Optional[Callable[[Post], bool]] = None, diff --git a/instaloader/structures.py b/instaloader/structures.py index f2ed0aa..29a80df 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -1862,7 +1862,9 @@ class Hashtag: return self._node["name"].lower() def _query(self, params): - json_response = self._context.get_json("explore/tags/{0}/".format(self.name), params) + json_response = self._context.get_iphone_json( + "api/v1/tags/web_info/", {**params, "tag_name": self.name} + ) return json_response["graphql"]["hashtag"] if "graphql" in json_response else json_response["data"] def _obtain_metadata(self):