diff --git a/instaloader/nodeiterator.py b/instaloader/nodeiterator.py index a49656d..bd9d4e1 100644 --- a/instaloader/nodeiterator.py +++ b/instaloader/nodeiterator.py @@ -77,7 +77,7 @@ class NodeIterator(Iterator[T]): query_variables: Optional[Dict[str, Any]] = None, query_referer: Optional[str] = None, first_data: Optional[Dict[str, Any]] = None, - is_first: Optional[Callable[[T], bool]] = None): + is_first: Optional[Callable[[T, Optional[T]], bool]] = None): self._context = context self._query_hash = query_hash self._edge_extractor = edge_extractor @@ -131,7 +131,7 @@ class NodeIterator(Iterator[T]): raise item = self._node_wrapper(node) if self._is_first is not None: - if self._is_first(item): + if self._is_first(item, self.first_item): self._first_node = node else: if self._first_node is None: diff --git a/instaloader/structures.py b/instaloader/structures.py index 46f6fe2..109c845 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -1039,17 +1039,8 @@ class Profile: ) @staticmethod - def _make_is_newest_checker() -> Callable[[Post], bool]: - newest_date: Optional[datetime] = None - def is_newest(p: Post) -> bool: - nonlocal newest_date - post_date = p.date_local - if newest_date is None or post_date > newest_date: - newest_date = post_date - return True - else: - return False - return is_newest + def _make_is_newest_checker() -> Callable[[Post, Optional[Post]], bool]: + return lambda post, first: first is None or post.date_local > first.date_local def get_followers(self) -> NodeIterator['Profile']: """