Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter follower extractor #6331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,16 @@ def items(self):
self.login()
return self._users_result(TwitterAPI(self).user_following(self.user))

class TwitterFollowersExtractor(TwitterExtractor):
"""Extractor for followed users"""
subcategory = "followers"
pattern = BASE_PATTERN + r"/(?!search)([^/?#]+)/followers(?!\w)"
example = "https://x.com/USER/followers"

def items(self):
self.login()
return self._users_result(TwitterAPI(self).user_followers(self.user))


class TwitterSearchExtractor(TwitterExtractor):
"""Extractor for Twitter search results"""
Expand Down Expand Up @@ -1142,6 +1152,10 @@ def __init__(self, extractor):
"longform_notetweets_inline_media_enabled": True,
"responsive_web_media_download_video_enabled": True,
"responsive_web_enhance_cards_enabled": False,
"communities_web_enable_tweet_community_results_fetch" : False,
"creator_subscriptions_quote_tweet_preview_enabled" : False,
"rweb_tipjar_consumption_enabled": False,
"articles_preview_enabled" : False,
}

def tweet_result_by_rest_id(self, tweet_id):
Expand Down Expand Up @@ -1342,6 +1356,15 @@ def user_following(self, screen_name):
}
return self._pagination_users(endpoint, variables)

def user_followers(self, screen_name):
endpoint = "/graphql/gwv4MK0diCpAJ79u7op1Lg/Followers"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"includePromotedContent": False,
}
return self._pagination_users(endpoint, variables)

@memcache(keyarg=1)
def user_by_rest_id(self, rest_id):
endpoint = "/graphql/tD8zKvQzwY3kdx5yz6YmOw/UserByRestId"
Expand Down
Loading