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 13, 2024
1 parent 2a98788 commit 6ae8b98
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 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.7'
__version__ = '1.4.8'

from .client import Client
from .errors import *
Expand Down
19 changes: 15 additions & 4 deletions twikit/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io
import json
import time
import warnings
from functools import partial
from typing import Literal

Expand Down Expand Up @@ -59,10 +60,13 @@ class Client:
... )
"""

def __init__(self, language: str | None = None, **kwargs) -> None:
def __init__(
self, language: str | None = None,
proxies: dict | None = None, **kwargs
) -> None:
self._token = TOKEN
self.language = language
self.http = HTTPClient(**kwargs)
self.http = HTTPClient(proxies=proxies, **kwargs)
self._user_id = None
self._user_agent = UserAgent().random.strip()
self._act_as = None
Expand Down Expand Up @@ -2464,8 +2468,15 @@ def _get_user_friendship(
for item in items:
entry_id = item['entryId']
if entry_id.startswith('user'):
user_info = find_dict(item, 'result')[0]
results.append(User(self, user_info))
user_info = find_dict(item, 'result')
if not user_info:
warnings.warn(
'Some followers are excluded because '
'"Quality Filter" is enabled. To get all followers, '
'turn this off this in the Twitter settings.'
)
continue
results.append(User(self, user_info[0]))
elif entry_id.startswith('cursor-bottom'):
next_cursor = item['content']['value']

Expand Down
18 changes: 14 additions & 4 deletions twikit/twikit_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import io
import json
import warnings
from functools import partial
from typing import Literal

Expand Down Expand Up @@ -60,10 +61,13 @@ class Client:
... )
"""

def __init__(self, language: str | None = None, **kwargs) -> None:
def __init__(
self, language: str | None = None,
proxies: dict | None = None, **kwargs
) -> None:
self._token = TOKEN
self.language = language
self.http = HTTPClient(**kwargs)
self.http = HTTPClient(proxies=proxies, **kwargs)
self._user_id = None
self._user_agent = UserAgent().random.strip()
self._act_as = None
Expand Down Expand Up @@ -2482,8 +2486,14 @@ async def _get_user_friendship(
for item in items:
entry_id = item['entryId']
if entry_id.startswith('user'):
user_info = find_dict(item, 'result')[0]
results.append(User(self, user_info))
user_info = find_dict(item, 'result')
if not user_info:
warnings.warn(
'Some followers are excluded because '
'"Quality Filter" is enabled. To get all followers, '
'turn this off this in the Twitter settings.'
)
continue
elif entry_id.startswith('cursor-bottom'):
next_cursor = item['content']['value']

Expand Down

0 comments on commit 6ae8b98

Please sign in to comment.