Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
d60 authored Apr 14, 2024
1 parent 6ae8b98 commit 940e31b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion twikit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
A Python library for interacting with the Twitter API.
"""

__version__ = '1.4.8'
__version__ = '1.4.9'

from .client import Client
from .errors import *
Expand Down
6 changes: 5 additions & 1 deletion twikit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,8 @@ def get_user_by_id(self, user_id: str) -> User:
if 'result' not in response['data']['user']:
raise TwitterException(f'Invalid user id: {user_id}')
user_data = response['data']['user']['result']
if user_data.get('__typename') == 'UserUnavailable':
raise UserUnavailable(user_data.get('message'))
return User(self, user_data)

def _get_tweet_detail(self, tweet_id: str, cursor: str | None):
Expand Down Expand Up @@ -2473,9 +2475,11 @@ def _get_user_friendship(
warnings.warn(
'Some followers are excluded because '
'"Quality Filter" is enabled. To get all followers, '
'turn this off this in the Twitter settings.'
'turn off it in the Twitter settings.'
)
continue
if user_info[0].get('__typename') == 'UserUnavailable':
continue
results.append(User(self, user_info[0]))
elif entry_id.startswith('cursor-bottom'):
next_cursor = item['content']['value']
Expand Down
6 changes: 5 additions & 1 deletion twikit/twikit_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,8 @@ async def get_user_by_id(self, user_id: str) -> User:
if 'result' not in response['data']['user']:
raise TwitterException(f'Invalid user id: {user_id}')
user_data = response['data']['user']['result']
if user_data.get('__typename') == 'UserUnavailable':
raise UserUnavailable(user_data.get('message'))
return User(self, user_data)

async def _get_tweet_detail(self, tweet_id: str, cursor: str | None):
Expand Down Expand Up @@ -2491,9 +2493,11 @@ async def _get_user_friendship(
warnings.warn(
'Some followers are excluded because '
'"Quality Filter" is enabled. To get all followers, '
'turn this off this in the Twitter settings.'
'turn off it in the Twitter settings.'
)
continue
if user_info[0].get('__typename') == 'UserUnavailable':
continue
elif entry_id.startswith('cursor-bottom'):
next_cursor = item['content']['value']

Expand Down
1 change: 1 addition & 0 deletions twikit/twikit_async/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def __init__(self, client: Client, data: dict) -> None:
self.is_translator: bool = legacy['is_translator']
self.translator_type: str = legacy['translator_type']
self.withheld_in_countries: list[str] = legacy['withheld_in_countries']
self.protected: bool = legacy.get('protected', False)

@property
def created_at_datetime(self) -> datetime:
Expand Down
1 change: 1 addition & 0 deletions twikit/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def __init__(self, client: Client, data: dict) -> None:
self.is_translator: bool = legacy['is_translator']
self.translator_type: str = legacy['translator_type']
self.withheld_in_countries: list[str] = legacy['withheld_in_countries']
self.protected: bool = legacy.get('protected', False)

@property
def created_at_datetime(self) -> datetime:
Expand Down

0 comments on commit 940e31b

Please sign in to comment.