diff options
| author | 2020-10-12 18:14:27 -0400 | |
|---|---|---|
| committer | 2020-10-12 18:14:27 -0400 | |
| commit | e0c914765184ebbf99cffdecfe8cdbe10f42486e (patch) | |
| tree | 4dd89f11195c3f58b3b62b9911bbdc40d0e44471 /gallery_dl/extractor/twitter.py | |
| parent | 9074eee175f76b824fbb6695d56426105191c51c (diff) | |
New upstream version 1.15.1.upstream/1.15.1
Diffstat (limited to 'gallery_dl/extractor/twitter.py')
| -rw-r--r-- | gallery_dl/extractor/twitter.py | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index 236a001..c98a300 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -110,16 +110,17 @@ class TwitterExtractor(Extractor): twitpics = [] for url in tweet["entities"].get("urls", ()): url = url["expanded_url"] - if "//twitpic.com/" in url: + if "//twitpic.com/" in url and "/photos/" not in url: response = self.request(url, fatal=False) if response.status_code >= 400: continue url = text.extract( response.text, 'name="twitter:image" value="', '"')[0] - twitpics.append({ - "original_info": {}, - "media_url" : url, - }) + if url: + twitpics.append({ + "original_info": {}, + "media_url" : url, + }) if twitpics: if "extended_entities" in tweet: tweet["extended_entities"]["media"].extend(twitpics) @@ -312,6 +313,7 @@ class TwitterSearchExtractor(TwitterExtractor): test = ("https://twitter.com/search?q=nature", { "range": "1-40", "count": 40, + "archive": False, }) def metadata(self): @@ -378,6 +380,15 @@ class TwitterTweetExtractor(TwitterExtractor): "url": "0f6a841e23948e4320af7ae41125e0c5b3cadc98", "content": "f29501e44d88437fe460f5c927b7543fda0f6e34", }), + # original retweets (#1026) + ("https://twitter.com/jessica_3978/status/1296304589591810048", { + "options": (("retweets", "original"),), + "count": 2, + "keyword": { + "tweet_id": 1296296016002547713, + "date" : "dt:2020-08-20 04:00:28", + }, + }), ) def __init__(self, match): @@ -451,7 +462,8 @@ class TwitterAPI(): endpoint = "2/timeline/conversation/{}.json".format(tweet_id) tweets = [] for tweet in self._pagination(endpoint): - if tweet["id_str"] == tweet_id: + if tweet["id_str"] == tweet_id or \ + tweet.get("_retweet_id_str") == tweet_id: tweets.append(tweet) if "quoted_status_id_str" in tweet: tweet_id = tweet["quoted_status_id_str"] @@ -536,6 +548,7 @@ class TwitterAPI(): entry_tweet="tweet-", entry_cursor="cursor-bottom-"): if params is None: params = self.params.copy() + original_retweets = (self.extractor.retweets == "original") while True: cursor = tweet = None @@ -558,12 +571,17 @@ class TwitterAPI(): "Skipping %s (deleted)", entry["entryId"][len(entry_tweet):]) continue - tweet["user"] = users[tweet["user_id_str"]] if "retweeted_status_id_str" in tweet: retweet = tweets.get(tweet["retweeted_status_id_str"]) - if retweet: + if original_retweets: + if not retweet: + continue + retweet["_retweet_id_str"] = tweet["id_str"] + tweet = retweet + elif retweet: tweet["author"] = users[retweet["user_id_str"]] + tweet["user"] = users[tweet["user_id_str"]] yield tweet if "quoted_status_id_str" in tweet: |
