From 2a3e5980ff540eb4dbf79db44fccec1fa55c9091 Mon Sep 17 00:00:00 2001 From: Yash Malik <37410163+codeblech@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:50:09 +0530 Subject: [PATCH 1/4] minor doc update in basic-usage.rst (#2336) (almost) nobody says "Id est". Even I, being a native English speaker, had to search for it. It should've been "i.e." in the first place. But, even that is not needed. Let's keep it simple. --- docs/basic-usage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic-usage.rst b/docs/basic-usage.rst index 7e349bb..bb352e6 100644 --- a/docs/basic-usage.rst +++ b/docs/basic-usage.rst @@ -231,7 +231,7 @@ The filter string must be a where the attributes from :class:`Post` or :class:`StoryItem` respectively are defined. -Id est, the following attributes can be used with both +The following attributes can be used with both :option:`--post-filter` and :option:`--storyitem-filter`: - :attr:`~Post.owner_username` (str), :attr:`~Post.owner_id` (int) From 3a952502650efd97ed0fd489b450a45f8f88f45a Mon Sep 17 00:00:00 2001 From: Alex Chan Date: Wed, 28 Aug 2024 07:27:58 +0100 Subject: [PATCH 2/4] Clarify that post short codes should be preceded by a hyphen (#2343) --- docs/basic-usage.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/basic-usage.rst b/docs/basic-usage.rst index bb352e6..d7608ba 100644 --- a/docs/basic-usage.rst +++ b/docs/basic-usage.rst @@ -122,7 +122,8 @@ Instaloader supports the following targets: - ``-post`` Replace **post** with the post's shortcode to download single post. Must be preceded by ``--`` in - the argument list to not be mistaken as an option flag:: + the argument list to not be mistaken as an option flag. For example, to download the post + https://www.instagram.com/p/**B_K4CykAOtf**, run the command:: instaloader -- -B_K4CykAOtf From 3a314de191b06d6bfda4b3f206e78b9bd4ceba19 Mon Sep 17 00:00:00 2001 From: Eduardo Kalinowski Date: Wed, 28 Aug 2024 03:28:35 -0300 Subject: [PATCH 3/4] Remove rhx_gis header support (#2340) The query used to obtain it does not work anymore. The parameter was only used when obtaining a profile by its id, when not logged in. This query is working fine without the special header, so the whole functionality concerning rhx_gis was removed. This also fixes this misleading messages logged when trying to obtain a profile anonymously: JSON Query to : Expecting value: line 1 column 1 (char 0) --- instaloader/instaloadercontext.py | 29 ++++++----------------------- instaloader/structures.py | 3 +-- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index 59101ed..34459be 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -1,4 +1,3 @@ -import hashlib import json import os import pickle @@ -94,7 +93,6 @@ class InstaloaderContext: self.quiet = quiet self.max_connection_attempts = max_connection_attempts self._graphql_page_length = 50 - self._root_rhx_gis = None self.two_factor_auth_pending = None self.iphone_support = iphone_support self.iphone_headers = default_iphone_headers() @@ -486,15 +484,17 @@ class InstaloaderContext: raise ConnectionException(error_string) from err def graphql_query(self, query_hash: str, variables: Dict[str, Any], - referer: Optional[str] = None, rhx_gis: Optional[str] = None) -> Dict[str, Any]: + referer: Optional[str] = None) -> Dict[str, Any]: """ Do a GraphQL Query. :param query_hash: Query identifying hash. :param variables: Variables for the Query. :param referer: HTTP Referer, or None. - :param rhx_gis: 'rhx_gis' variable as somewhere returned by Instagram, needed to 'sign' request :return: The server's response dictionary. + + .. versionchanged:: 4.13.1 + Removed the `rhx_gis` parameter. """ with copy_session(self._session, self.request_timeout) as tmpsession: tmpsession.headers.update(self._default_http_header(empty_session_only=True)) @@ -508,12 +508,6 @@ class InstaloaderContext: variables_json = json.dumps(variables, separators=(',', ':')) - if rhx_gis: - #self.log("rhx_gis {} query_hash {}".format(rhx_gis, query_hash)) - values = "{}:{}".format(rhx_gis, variables_json) - x_instagram_gis = hashlib.md5(values.encode()).hexdigest() - tmpsession.headers['x-instagram-gis'] = x_instagram_gis - resp_json = self.get_json('graphql/query', params={'query_hash': query_hash, 'variables': variables_json}, @@ -559,7 +553,7 @@ class InstaloaderContext: def graphql_node_list(self, query_hash: str, query_variables: Dict[str, Any], query_referer: Optional[str], edge_extractor: Callable[[Dict[str, Any]], Dict[str, Any]], - rhx_gis: Optional[str] = None, + _rhx_gis: Optional[str] = None, first_data: Optional[Dict[str, Any]] = None) -> Iterator[Dict[str, Any]]: """ Retrieve a list of GraphQL nodes. @@ -571,7 +565,7 @@ class InstaloaderContext: def _query(): query_variables['first'] = self._graphql_page_length try: - return edge_extractor(self.graphql_query(query_hash, query_variables, query_referer, rhx_gis)) + return edge_extractor(self.graphql_query(query_hash, query_variables, query_referer)) except QueryReturnedBadRequestException: new_page_length = int(self._graphql_page_length / 2) if new_page_length >= 12: @@ -720,17 +714,6 @@ class InstaloaderContext: raise QueryReturnedNotFoundException(self._response_error(resp)) raise ConnectionException(self._response_error(resp)) - @property - def root_rhx_gis(self) -> Optional[str]: - """rhx_gis string returned in the / query.""" - if self.is_logged_in: - # At the moment, rhx_gis seems to be required for anonymous requests only. By returning None when logged - # in, we can save the root_rhx_gis lookup query. - return None - if self._root_rhx_gis is None: - self._root_rhx_gis = self.get_json('', {}).get('rhx_gis', '') - return self._root_rhx_gis or None - class RateController: """ diff --git a/instaloader/structures.py b/instaloader/structures.py index 1dd43d9..c9ae5a1 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -908,8 +908,7 @@ class Profile: 'include_reel': True, 'include_suggested_users': False, 'include_logged_out_extras': False, - 'include_highlight_reels': False}, - rhx_gis=context.root_rhx_gis)['data']['user'] + 'include_highlight_reels': False})['data']['user'] if data: profile = cls(context, data['reel']['owner']) else: From c5dacb5f6d8bebbfb7ce2a448e32866ecd2d9868 Mon Sep 17 00:00:00 2001 From: Alexander Graf <17130992+aandergr@users.noreply.github.com> Date: Wed, 28 Aug 2024 08:29:57 +0200 Subject: [PATCH 4/4] Release of version 4.13.1 --- instaloader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instaloader/__init__.py b/instaloader/__init__.py index 506f152..8da6016 100644 --- a/instaloader/__init__.py +++ b/instaloader/__init__.py @@ -1,7 +1,7 @@ """Download pictures (or videos) along with their captions and other metadata from Instagram.""" -__version__ = '4.13' +__version__ = '4.13.1' try: