Skip to content

Commit

Permalink
[twitter] add fallback URLs (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Apr 30, 2019
1 parent 1c665fd commit dcc1592
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TwitterExtractor(Extractor):
filename_fmt = "{tweet_id}_{num}.{extension}"
archive_fmt = "{tweet_id}_{retweet_id}_{num}"
root = "https://twitter.com"
sizes = (":orig", ":large", ":medium", ":small")

def __init__(self, match):
Extractor.__init__(self, match)
Expand All @@ -41,7 +42,8 @@ def items(self):
tweet, 'data-image-url="', '"')
for data["num"], url in enumerate(images, 1):
text.nameext_from_url(url, data)
yield Message.Url, url + ":orig", data
urls = [url + size for size in self.sizes]
yield Message.Urllist, urls, data

if self.videos and "-videoContainer" in tweet:
data["num"] = 1
Expand Down

0 comments on commit dcc1592

Please sign in to comment.