diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 128b04e..3215aaf 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -756,8 +756,10 @@ class Instaloader: while True: feed = data["user"]["edge_web_feed_timeline"] - yield from (Post(self.context, edge["node"]) for edge in feed["edges"] - if not edge["node"]["__typename"] == "GraphSuggestedUserFeedUnit") + for edge in feed["edges"]: + node = edge["node"] + if node.get("__typename") in Post.supported_graphql_types() and node.get("shortcode") is not None: + yield Post(self.context, node) if not feed["page_info"]["has_next_page"]: break data = self.context.graphql_query("d6f4427fbe92d846298cf93df0b937d3", diff --git a/instaloader/structures.py b/instaloader/structures.py index 50f2d14..b351abd 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -98,6 +98,11 @@ class Post: raise InvalidArgumentException("Wrong mediaid {0}, unable to convert to shortcode".format(str(mediaid))) return b64encode(mediaid.to_bytes(9, 'big'), b'-_').decode().replace('A', ' ').lstrip().replace(' ', 'A') + @staticmethod + def supported_graphql_types() -> List[str]: + """The values of __typename fields that the :class:`Post` class can handle.""" + return ["GraphImage", "GraphVideo", "GraphSidecar"] + def _asdict(self): node = self._node if self._full_metadata_dict: