From f2e8aedd746bd570a79d0289aaad68a00dbcf9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 15 Jan 2022 22:02:57 +0100 Subject: [PATCH] [twitter] changes to 'cards' option - change default value to 'true' - only invoke youtube-dl for cards unsupported by gallery when 'cards' is set to "ytdl" "cards": true --> only download card images "cards": "ytdl" --> download card images and use youtube_dl on otherwise unsupported cards --- docs/configuration.rst | 10 +++++++--- docs/gallery-dl.conf | 2 +- gallery_dl/extractor/twitter.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index a1064ae0..bcf94efe 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2030,11 +2030,15 @@ Description extractor.twitter.cards ----------------------- Type - ``bool`` + ``bool`` or ``string`` Default - ``false`` + ``true`` Description - Fetch media from `Cards `__. + Controls how to handle `Twitter Cards `__. + + * ``false``: Ignore cards + * ``true``: Download image content from supported cards + * ``"ytdl"``: Additionally download video content from unsupported cards using `youtube-dl`_ extractor.twitter.conversations diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 8e7ff6db..30be8402 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -265,7 +265,7 @@ { "username": null, "password": null, - "cards": false, + "cards": true, "conversations": false, "pinned": false, "quoted": false, diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index 02df711a..00d443e2 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -39,7 +39,7 @@ class TwitterExtractor(Extractor): self.pinned = self.config("pinned", False) self.quoted = self.config("quoted", False) self.videos = self.config("videos", True) - self.cards = self.config("cards", False) + self.cards = self.config("cards", True) self._user_cache = {} self._init_sizes() @@ -165,7 +165,7 @@ class TwitterExtractor(Extractor): tweet, data["media_entities"].values(), files) return - if self.videos: + if self.cards == "ytdl": url = "ytdl:{}/i/web/status/{}".format(self.root, tweet["id_str"]) files.append({"url": url})