Skip to content

Commit

Permalink
[twitter] general support for unified cards (#2875)
Browse files Browse the repository at this point in the history
just removing the 'type' check seems to work
  • Loading branch information
mikf committed Aug 31, 2022
1 parent 8839b0d commit 4d7cb0b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ def _extract_card(self, tweet, files):
else:
bval = bvals["unified_card"]["string_value"]
data = json.loads(bval)
if data.get("type") in ("image_website", "image_carousel_website"):
self._extract_media(
tweet, data["media_entities"].values(), files)
return
self._extract_media(tweet, data["media_entities"].values(), files)
return

if self.cards == "ytdl":
tweet_id = tweet.get("rest_id") or tweet["id_str"]
Expand Down Expand Up @@ -735,18 +733,23 @@ class TwitterTweetExtractor(TwitterExtractor):
"options": (("cards", True),),
"pattern": r"https://pbs.twimg.com/card_img/\d+/",
}),
# image_website unified_card (#2875)
# unified_card image_website (#2875)
("https://twitter.com/i/web/status/1561674543323910144", {
"options": (("cards", True),),
"pattern": r"https://pbs\.twimg\.com/media/F.+=jpg",
"count": 1,
}),
# image_carousel_website unified_card
# unified_card image_carousel_website
("https://twitter.com/doax_vv_staff/status/1479438945662685184", {
"options": (("cards", True),),
"pattern": r"https://pbs\.twimg\.com/media/F.+=png",
"count": 6,
}),
# unified_card video_website (#2875)
("https://twitter.com/bang_dream_1242/status/1561548715348746241", {
"options": (("cards", True),),
"pattern": r"https://video\.twimg\.com/amplify_video"
r"/1560607284333449216/vid/720x720/\w+\.mp4",
}),
# unified_card without type
("https://twitter.com/i/web/status/1466183847628865544", {
"count": 0,
Expand Down

0 comments on commit 4d7cb0b

Please sign in to comment.