From 8d0801ad8ec85a929fd0f80a36ac8ce6b83b8c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 20 Jul 2022 15:12:08 +0200 Subject: [PATCH] [twitter] fall back to unfiltered search (#2766) --- gallery_dl/extractor/twitter.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index 34c9bb623c2..6aeffd09ecd 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -454,7 +454,6 @@ def tweets(self): tweet = None for tweet in self._select_tweet_source()(self.user): yield tweet - if tweet is None: return @@ -463,12 +462,19 @@ def tweets(self): self._user["name"], tweet["rest_id"]) if self.retweets: query += " include:retweets include:nativeretweets" + if not self.textonly: - query += (" (filter:images OR" - " filter:native_video OR" - " card_name:animated_gif)") + # try to search for media-only tweets + tweet = None + for tweet in self.api.search_adaptive(query + ( + " (filter:images OR" + " filter:native_video OR" + " card_name:animated_gif)")): + yield tweet + if tweet is not None: + return - # yield search results starting from last tweet id + # yield unfiltered search results yield from self.api.search_adaptive(query) def _select_tweet_source(self):