From ab58c375b45b86c4e6d0c623d2285abe4ebe3fbf Mon Sep 17 00:00:00 2001 From: ClosedPort22 <44864697+ClosedPort22@users.noreply.github.com> Date: Fri, 20 Jan 2023 13:18:23 +0800 Subject: [PATCH] [twitter] fix search (#3536) - partially revert 18fe4b334db0fbfa21fe932b73a2e64ebdd456a8 - properly search for cursor when processing 'replaceEntry' --- gallery_dl/extractor/twitter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index e8a1754b0f..17a2202be3 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -1101,7 +1101,7 @@ def search_adaptive(self, query): endpoint = "/2/search/adaptive.json" params = self.params.copy() params["q"] = query - # params["tweet_search_mode"] = "live" + params["tweet_search_mode"] = "live" params["query_source"] = "typed_query" params["pc"] = "1" params["spelling_corrections"] = "1" @@ -1241,6 +1241,7 @@ def _call(self, endpoint, params, method="GET", auth=True): def _pagination_legacy(self, endpoint, params): original_retweets = (self.extractor.retweets == "original") + bottom = ("cursor-bottom-", "sq-cursor-bottom") while True: data = self._call(endpoint, params) @@ -1261,7 +1262,7 @@ def _pagination_legacy(self, endpoint, params): entries = instr["addEntries"]["entries"] elif "replaceEntry" in instr: entry = instr["replaceEntry"]["entry"] - if entry["entryId"].startswith("cursor-bottom-"): + if entry["entryId"].startswith(bottom): cursor = (entry["content"]["operation"] ["cursor"]["value"]) @@ -1278,7 +1279,7 @@ def _pagination_legacy(self, endpoint, params): entry["content"]["timelineModule"]["metadata"] ["conversationMetadata"]["allTweetIds"][::-1]) - elif entry_startswith(("cursor-bottom-", "sq-cursor-bottom")): + elif entry_startswith(bottom): cursor = entry["content"]["operation"]["cursor"] if not cursor.get("stopOnEmptyResponse", True): # keep going even if there are no tweets