diff --git a/docs/configuration.rst b/docs/configuration.rst index 7a988e1bda7..90ec847a68d 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1650,6 +1650,20 @@ Description Extract `TwitPic `__ embeds. +extractor.twitter.users +----------------------- +Type + ``string`` +Default + ``"timeline"`` +Description + Output format for user results from + ``following`` and ``list-members`` queries. + + * ``"timeline"``: ``https://twitter.com/i/user/USERID`` + * ``"media"``: ``https://twitter.com/id:USERID/media`` + + extractor.twitter.videos ------------------------ Type diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 12b8e4fb62e..ca34eb51556 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -254,6 +254,7 @@ "replies": true, "retweets": true, "twitpic": false, + "users": "timeline", "videos": true }, "unsplash": diff --git a/gallery_dl/extractor/twitter.py b/gallery_dl/extractor/twitter.py index a7d2de5f09d..af5c0a3ded9 100644 --- a/gallery_dl/extractor/twitter.py +++ b/gallery_dl/extractor/twitter.py @@ -224,6 +224,18 @@ def _transform_user(self, user): } return cache[uid] + def _users_result(self, users): + if self.config("users") == "media": + cls = TwitterMediaExtractor + fmt = "{}/id:{}/media".format + else: + cls = TwitterTimelineExtractor + fmt = "{}/i/user/{}".format + + for user in users: + user["_extractor"] = cls + yield Message.Queue, fmt(self.root, user["rest_id"]), user + def metadata(self): """Return general metadata""" return {} @@ -356,10 +368,7 @@ class TwitterListMembersExtractor(TwitterExtractor): def items(self): self.login() - for user in TwitterAPI(self).list_members(self.user): - user["_extractor"] = TwitterTimelineExtractor - url = "{}/i/user/{}".format(self.root, user["rest_id"]) - yield Message.Queue, url, user + return self._users_result(TwitterAPI(self).list_members(self.user)) class TwitterFollowingExtractor(TwitterExtractor): @@ -373,10 +382,7 @@ class TwitterFollowingExtractor(TwitterExtractor): def items(self): self.login() - for user in TwitterAPI(self).user_following(self.user): - user["_extractor"] = TwitterTimelineExtractor - url = "{}/i/user/{}".format(self.root, user["rest_id"]) - yield Message.Queue, url, user + return self._users_result(TwitterAPI(self).user_following(self.user)) class TwitterSearchExtractor(TwitterExtractor):