diff --git a/instaloader/__init__.py b/instaloader/__init__.py index b5d37d9..df79227 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.3' +__version__ = '4.3.2' try: diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index 24305b0..b1458ff 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -113,7 +113,7 @@ class InstaloaderContext: def close(self): """Print error log and close session""" if self.error_log and not self.quiet: - print("\nErrors occured:", file=sys.stderr) + print("\nErrors occurred:", file=sys.stderr) for err in self.error_log: print(err, file=sys.stderr) self._session.close() @@ -349,7 +349,7 @@ class InstaloaderContext: else: self._graphql_query_timestamps[query_hash].append(time.monotonic()) else: - text_for_429 = ("HTTP error code 429 was returned because too many queries occured in the last time. " + text_for_429 = ("HTTP error code 429 was returned because too many queries occurred in the last time. " "Please do not use Instagram in your browser or run multiple instances of Instaloader " "in parallel.") print(textwrap.fill(text_for_429), file=sys.stderr) diff --git a/instaloader/structures.py b/instaloader/structures.py index 87d9fba..bd00d80 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -139,6 +139,12 @@ class Post: pic_json = self._context.get_json("p/{0}/".format(self.shortcode), params={}) self._full_metadata_dict = pic_json['entry_data']['PostPage'][0]['graphql']['shortcode_media'] self._rhx_gis_str = pic_json.get('rhx_gis') + if self._full_metadata_dict is None: + # issue #449 + self._context.error("Fetching Post metadata failed (issue #449). " + "The following data has been returned:\n" + + json.dumps(pic_json['entry_data'], indent=2)) + raise BadResponseException("Fetching Post metadata failed.") if self.shortcode != self._full_metadata_dict['shortcode']: self._node.update(self._full_metadata_dict) raise PostChangedException @@ -229,7 +235,11 @@ class Post: def get_sidecar_nodes(self) -> Iterator[PostSidecarNode]: """Sidecar nodes of a Post with typename==GraphSidecar.""" if self.typename == 'GraphSidecar': - for edge in self._field('edge_sidecar_to_children', 'edges'): + edges = self._field('edge_sidecar_to_children', 'edges') + if any(edge['node']['is_video'] for edge in edges): + # video_url is only present in full metadata, issue #558. + edges = self._full_metadata['edge_sidecar_to_children']['edges'] + for edge in edges: node = edge['node'] is_video = node['is_video'] yield PostSidecarNode(is_video=is_video, display_url=node['display_url'],