still figuring out the architecture of this app

This commit is contained in:
msk
2022-09-20 15:34:38 -07:00
parent 2ab28ec5c8
commit 531f856bdc
5 changed files with 22 additions and 16 deletions
+8 -10
View File
@@ -1,3 +1,4 @@
from math import inf
import tweepy
import secrets
@@ -10,20 +11,17 @@ class API:
API.instance = self
self.client = tweepy.Client(
bearer_token=secrets.bearer_token(),
# consumer_key=secrets.api_key(),
# consumer_secret=secrets.api_secret(),
# access_token=secrets.access_token(),
# access_token_secret=secrets.access_secret()
consumer_key=secrets.api_key(), consumer_secret=secrets.api_secret(),
access_token=secrets.access_token(), access_token_secret=secrets.access_secret()
)
def get_tweets(self, id: int, count=5):
def get_user_tweets(self, id: int, count=inf):
posts = list()
step = util.clamp(count, 5, 100)
retrieve_size = util.clamp(count, 5, 100)
retrieved_tweets = 0
pagination_token = None
# while retrieved_tweets < count:
resp = self.client.get_users_tweets(id, max_results=count)
print(resp)
# while retrieved_tweets < count: # or we haven't reached the end of user's tweets
resp = self.client.get_users_tweets(id, max_results=retrieve_size, media_fields=['url'], expansions=['entities.mentions.username', 'referenced_tweets.id.author_id'])
return resp