Skip to content

Commit

Permalink
[twitter] warn about 'withheld' Tweets and users (#3864)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Apr 4, 2023
1 parent 3cc1dd1 commit dbe06cd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def items(self):
continue
seen_tweets.add(data["id_str"])

if "withheld_scope" in data:
txt = data.get("full_text") or data.get("text") or ""
self.log.warning("'%s' (%s)", txt, data["id_str"])

files = []
if "extended_entities" in data:
self._extract_media(
Expand Down Expand Up @@ -321,8 +325,10 @@ def _transform_user(self, user):
user = self.api.user_by_screen_name(user["screen_name"])["legacy"]

uget = user.get
entities = user["entities"]
if uget("withheld_scope"):
self.log.warning("'%s'", uget("description"))

entities = user["entities"]
self._user_cache[uid] = udata = {
"id" : text.parse_int(uid),
"name" : user["screen_name"],
Expand Down Expand Up @@ -1582,10 +1588,17 @@ def _pagination_tweets(self, endpoint, variables,
retweet["rest_id"]
tweet["author"] = \
retweet["core"]["user_results"]["result"]
if "extended_entities" in retweet["legacy"] and \

rtlegacy = retweet["legacy"]
if "extended_entities" in rtlegacy and \
"extended_entities" not in legacy:
legacy["extended_entities"] = \
retweet["legacy"]["extended_entities"]
rtlegacy["extended_entities"]
if "withheld_scope" in rtlegacy and \
"withheld_scope" not in legacy:
legacy["withheld_scope"] = \
rtlegacy["withheld_scope"]
legacy["full_text"] = rtlegacy["full_text"]
except KeyError:
pass

Expand Down

0 comments on commit dbe06cd

Please sign in to comment.