Skip to content

Commit

Permalink
merge #3549: [twitter] fix search (#3536)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jan 20, 2023
2 parents 02e314c + ab58c37 commit 137de09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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"])

Expand All @@ -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
Expand Down

0 comments on commit 137de09

Please sign in to comment.