From 15cd114c9c3c5e6bc12f9dc1573029dcc4b70d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 9 Nov 2022 20:40:51 +0100 Subject: [PATCH] [twitter] update bookmarks pagination (#3172) Do not stop when there aren't any tweets in a batch, but only when the same cursor value appears twice in a row. --- gallery_dl/extractor/twitter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index 078118f7..320bd3c5 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -1021,7 +1021,7 @@ class TwitterAPI(): "count": 100, } return self._pagination_tweets( - endpoint, variables, ("bookmark_timeline", "timeline")) + endpoint, variables, ("bookmark_timeline", "timeline"), False) def list_latest_tweets_timeline(self, list_id): endpoint = "/graphql/z3l-EHlx-fyg8OvGO4JN8A/ListLatestTweetsTimeline" @@ -1253,7 +1253,8 @@ class TwitterAPI(): return params["cursor"] = cursor - def _pagination_tweets(self, endpoint, variables, path=None): + def _pagination_tweets(self, endpoint, variables, + path=None, stop_tweets=True): extr = self.extractor variables.update(self.variables) original_retweets = (extr.retweets == "original") @@ -1397,7 +1398,9 @@ class TwitterAPI(): tweet.get("rest_id")) continue - if not tweet or not cursor: + if stop_tweets and not tweet: + return + if not cursor or cursor == variables.get("cursor"): return variables["cursor"] = cursor