diff options
Diffstat (limited to 'gallery_dl/extractor/twitter.py')
| -rw-r--r-- | gallery_dl/extractor/twitter.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index c323fe0..afeebb0 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -32,6 +32,7 @@ class TwitterExtractor(Extractor): def __init__(self, match): Extractor.__init__(self, match) self.user = match.group(1) + self.textonly = self.config("text-tweets", False) self.retweets = self.config("retweets", True) self.replies = self.config("replies", True) self.twitpic = self.config("twitpic", False) @@ -64,7 +65,7 @@ class TwitterExtractor(Extractor): self._extract_card(tweet, files) if self.twitpic: self._extract_twitpic(tweet, files) - if not files: + if not files and not self.textonly: continue tdata = self._transform_tweet(tweet) @@ -168,7 +169,6 @@ class TwitterExtractor(Extractor): tweet["created_at"], "%a %b %d %H:%M:%S %z %Y"), "user" : self._transform_user(tweet["user"]), "lang" : tweet["lang"], - "content" : tweet["full_text"], "favorite_count": tweet["favorite_count"], "quote_count" : tweet["quote_count"], "reply_count" : tweet["reply_count"], @@ -187,6 +187,14 @@ class TwitterExtractor(Extractor): "nick": u["name"], } for u in mentions] + content = tweet["full_text"] + urls = entities.get("urls") + if urls: + for url in urls: + content = content.replace(url["url"], url["expanded_url"]) + txt, _, tco = content.rpartition(" ") + tdata["content"] = txt if tco.startswith("https://t.co/") else content + if "in_reply_to_screen_name" in tweet: tdata["reply_to"] = tweet["in_reply_to_screen_name"] @@ -489,6 +497,10 @@ class TwitterTweetExtractor(TwitterExtractor): "options": (("conversations", True),), "count": ">= 50", }), + # retweet with missing media entities (#1555) + ("https://twitter.com/morino_ya/status/1392763691599237121", { + "count": 4, + }), ) def __init__(self, match): @@ -802,6 +814,10 @@ class TwitterAPI(): tweet = retweet elif retweet: tweet["author"] = users[retweet["user_id_str"]] + if "extended_entities" in retweet and \ + "extended_entities" not in tweet: + tweet["extended_entities"] = \ + retweet["extended_entities"] tweet["user"] = users[tweet["user_id_str"]] yield tweet |
