[twitter] add 'limit' option (#8173)

- reduce default number of requested items to 50
- allow using "fallback" values like with 'search-limit'

https://github.com/mikf/gallery-dl/issues/8173#issuecomment-3303015837
This commit is contained in:
Mike Fährmann
2025-12-02 20:42:08 +01:00
parent 0ebb74dfeb
commit d15b3d4eae
3 changed files with 30 additions and 12 deletions

View File

@@ -6215,6 +6215,23 @@ Description
* ``360x360``
extractor.twitter.limit
-----------------------
Type
* ``integer``
* ``list`` of ``integers``
Default
``50``
Example
``[40, 30, 20, 10, 5]``
Description
Number of requested results per API query.
When given as a ``list``,
start with the first element as ``count`` parameter
and switch to the next element whenever no results are returned.
extractor.twitter.logout
------------------------
Type

View File

@@ -871,6 +871,7 @@
"cursor" : true,
"expand" : false,
"include" : ["timeline"],
"limit" : 50,
"locked" : "abort",
"logout" : true,
"pinned" : false,

View File

@@ -1370,7 +1370,7 @@ class TwitterAPI():
endpoint = "/graphql/E8Wq-_jFSaU7hxVcuOPR9g/UserTweets"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"withQuickPromoteEligibilityTweetFields": False,
"withVoice": True,
@@ -1385,7 +1385,7 @@ class TwitterAPI():
endpoint = "/graphql/-O3QOHrVn1aOm_cF5wyTCQ/UserTweetsAndReplies"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"withCommunity": True,
"withVoice": True,
@@ -1400,7 +1400,7 @@ class TwitterAPI():
endpoint = "/graphql/gmHw9geMTncZ7jeLLUUNOw/UserHighlightsTweets"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"withVoice": True,
}
@@ -1414,7 +1414,7 @@ class TwitterAPI():
endpoint = "/graphql/jCRhbOzdgOHp6u9H4g2tEg/UserMedia"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"withClientEventToken": False,
"withBirdwatchNotes": False,
@@ -1430,7 +1430,7 @@ class TwitterAPI():
endpoint = "/graphql/TGEKkJG_meudeaFcqaxM-Q/Likes"
variables = {
"userId": self._user_id_by_screen_name(screen_name),
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"withClientEventToken": False,
"withBirdwatchNotes": False,
@@ -1445,7 +1445,7 @@ class TwitterAPI():
def user_bookmarks(self):
endpoint = "/graphql/pLtjrO4ubNh996M_Cubwsg/Bookmarks"
variables = {
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
}
return self._pagination_tweets(
@@ -1508,7 +1508,7 @@ class TwitterAPI():
endpoint = "/graphql/Nyt-88UX4-pPCImZNUl9RQ/CommunityTweetsTimeline"
variables = {
"communityId": community_id,
"count": 100,
"count": self.extractor.config("limit", 50),
"displayLocation": "Community",
"rankingMode": "Recency",
"withCommunity": True,
@@ -1522,7 +1522,7 @@ class TwitterAPI():
endpoint = "/graphql/ZniZ7AAK_VVu1xtSx1V-gQ/CommunityMediaTimeline"
variables = {
"communityId": community_id,
"count": 100,
"count": self.extractor.config("limit", 50),
"withCommunity": True,
}
return self._pagination_tweets(
@@ -1534,7 +1534,7 @@ class TwitterAPI():
endpoint = ("/graphql/p048a9n3hTPppQyK7FQTFw"
"/CommunitiesMainPageTimeline")
variables = {
"count": 100,
"count": self.extractor.config("limit", 50),
"withCommunity": True,
}
return self._pagination_tweets(
@@ -1544,7 +1544,7 @@ class TwitterAPI():
def home_timeline(self):
endpoint = "/graphql/DXmgQYmIft1oLP6vMkJixw/HomeTimeline"
variables = {
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"latestControlAvailable": True,
"withCommunity": True,
@@ -1555,7 +1555,7 @@ class TwitterAPI():
def home_latest_timeline(self):
endpoint = "/graphql/SFxmNKWfN9ySJcXG_tjX8g/HomeLatestTimeline"
variables = {
"count": 100,
"count": self.extractor.config("limit", 50),
"includePromotedContent": False,
"latestControlAvailable": True,
}
@@ -1582,7 +1582,7 @@ class TwitterAPI():
endpoint = "/graphql/06JtmwM8k_1cthpFZITVVA/ListLatestTweetsTimeline"
variables = {
"listId": list_id,
"count": 100,
"count": self.extractor.config("limit", 50),
}
return self._pagination_tweets(
endpoint, variables, ("list", "tweets_timeline", "timeline"))