From aed1c63e5151c0a71ad72c978cebf884c566d81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 21 Jun 2020 15:43:27 +0200 Subject: [PATCH] [twitter] improve search results (fixes #847) Adding 'tweet_search_mode=live' to the query parameters is the most important part here. --- gallery_dl/extractor/twitter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index 88c42e7e..3d17eb48 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -302,7 +302,7 @@ class TwitterSearchExtractor(TwitterExtractor): return {"search": text.unquote(self.user)} def tweets(self): - return TwitterAPI(self).search(self.user) + return TwitterAPI(self).search(text.unquote(self.user)) class TwitterTweetExtractor(TwitterExtractor): @@ -449,7 +449,11 @@ class TwitterAPI(): def search(self, query): endpoint = "2/search/adaptive.json" params = self.params.copy() - params["q"] = text.unquote(query) + params["q"] = query + params["tweet_search_mode"] = "live" + params["query_source"] = "typed_query" + params["pc"] = "1" + params["spelling_corrections"] = "1" return self._pagination( endpoint, params, "sq-I-t-", "sq-cursor-bottom")