[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.
This commit is contained in:
Mike Fährmann
2022-11-09 20:40:51 +01:00
parent 550f90ab56
commit 15cd114c9c

View File

@@ -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