twitter-openapi-python 0.0.44__py3-none-any.whl → 0.0.45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- twitter_openapi_python/__init__.py +15 -15
- twitter_openapi_python/api/__init__.py +13 -13
- twitter_openapi_python/api/default_api.py +80 -80
- twitter_openapi_python/api/initial_state_api.py +72 -72
- twitter_openapi_python/api/post_api.py +166 -166
- twitter_openapi_python/api/tweet_api.py +428 -353
- twitter_openapi_python/api/user_api.py +80 -80
- twitter_openapi_python/api/user_list_api.py +171 -171
- twitter_openapi_python/api/users_api.py +56 -56
- twitter_openapi_python/api/v11_get_api.py +67 -70
- twitter_openapi_python/api/v11_post_api.py +61 -66
- twitter_openapi_python/client.py +194 -194
- twitter_openapi_python/models/__init__.py +22 -22
- twitter_openapi_python/models/base.py +9 -9
- twitter_openapi_python/models/header.py +20 -20
- twitter_openapi_python/models/initial_state.py +17 -17
- twitter_openapi_python/models/response.py +19 -19
- twitter_openapi_python/models/timeline.py +40 -40
- twitter_openapi_python/tid.py +27 -17
- twitter_openapi_python/utils/__init__.py +22 -22
- twitter_openapi_python/utils/api.py +288 -288
- {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.0.45.dist-info}/METADATA +118 -117
- twitter_openapi_python-0.0.45.dist-info/RECORD +27 -0
- {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.0.45.dist-info}/WHEEL +1 -2
- {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE +31 -31
- {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE.AGPL +660 -660
- twitter_openapi_python-0.0.44.dist-info/RECORD +0 -28
- twitter_openapi_python-0.0.44.dist-info/top_level.txt +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
|
-
# flake8: noqa
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
from twitter_openapi_python.models.base import BaseModel
|
|
7
|
-
from twitter_openapi_python.models.header import ApiUtilsHeader
|
|
8
|
-
from twitter_openapi_python.models.initial_state import (
|
|
9
|
-
InitialStateApiUtilsRaw,
|
|
10
|
-
InitialStateApiUtilsResponse,
|
|
11
|
-
)
|
|
12
|
-
from twitter_openapi_python.models.response import (
|
|
13
|
-
TwitterApiUtilsRaw,
|
|
14
|
-
TwitterApiUtilsResponse,
|
|
15
|
-
)
|
|
16
|
-
from twitter_openapi_python.models.timeline import (
|
|
17
|
-
ApiUtilsRaw,
|
|
18
|
-
CursorApiUtilsResponse,
|
|
19
|
-
TimelineApiUtilsResponse,
|
|
20
|
-
TweetApiUtilsData,
|
|
21
|
-
UserApiUtilsData,
|
|
22
|
-
)
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from twitter_openapi_python.models.base import BaseModel
|
|
7
|
+
from twitter_openapi_python.models.header import ApiUtilsHeader
|
|
8
|
+
from twitter_openapi_python.models.initial_state import (
|
|
9
|
+
InitialStateApiUtilsRaw,
|
|
10
|
+
InitialStateApiUtilsResponse,
|
|
11
|
+
)
|
|
12
|
+
from twitter_openapi_python.models.response import (
|
|
13
|
+
TwitterApiUtilsRaw,
|
|
14
|
+
TwitterApiUtilsResponse,
|
|
15
|
+
)
|
|
16
|
+
from twitter_openapi_python.models.timeline import (
|
|
17
|
+
ApiUtilsRaw,
|
|
18
|
+
CursorApiUtilsResponse,
|
|
19
|
+
TimelineApiUtilsResponse,
|
|
20
|
+
TweetApiUtilsData,
|
|
21
|
+
UserApiUtilsData,
|
|
22
|
+
)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from typing import TypeVar
|
|
2
|
-
|
|
3
|
-
from pydantic import BaseModel as PydanticBaseModel
|
|
4
|
-
|
|
5
|
-
T = TypeVar("T")
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class BaseModel(PydanticBaseModel):
|
|
9
|
-
model_config = {"arbitrary_types_allowed": True}
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel as PydanticBaseModel
|
|
4
|
+
|
|
5
|
+
T = TypeVar("T")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BaseModel(PydanticBaseModel):
|
|
9
|
+
model_config = {"arbitrary_types_allowed": True}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
from typing import Dict, Optional
|
|
2
|
-
|
|
3
|
-
from pydantic import Field
|
|
4
|
-
|
|
5
|
-
from twitter_openapi_python.models import BaseModel
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class ApiUtilsHeader(BaseModel):
|
|
9
|
-
raw: Dict[str, str] = Field()
|
|
10
|
-
connection_hash: Optional[str] = Field()
|
|
11
|
-
content_type_options: Optional[str] = Field()
|
|
12
|
-
frame_options: Optional[str] = Field()
|
|
13
|
-
response_time: int = Field()
|
|
14
|
-
tfe_preserve_body: bool = Field()
|
|
15
|
-
transaction_id: Optional[str] = Field()
|
|
16
|
-
xss_protection: Optional[int] = Field()
|
|
17
|
-
rate_limit_limit: int = Field()
|
|
18
|
-
rate_limit_remaining: int = Field()
|
|
19
|
-
rate_limit_reset: int = Field()
|
|
20
|
-
twitter_response_tags: Optional[str] = Field()
|
|
1
|
+
from typing import Dict, Optional
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from twitter_openapi_python.models import BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ApiUtilsHeader(BaseModel):
|
|
9
|
+
raw: Dict[str, str] = Field()
|
|
10
|
+
connection_hash: Optional[str] = Field()
|
|
11
|
+
content_type_options: Optional[str] = Field()
|
|
12
|
+
frame_options: Optional[str] = Field()
|
|
13
|
+
response_time: int = Field()
|
|
14
|
+
tfe_preserve_body: bool = Field()
|
|
15
|
+
transaction_id: Optional[str] = Field()
|
|
16
|
+
xss_protection: Optional[int] = Field()
|
|
17
|
+
rate_limit_limit: int = Field()
|
|
18
|
+
rate_limit_remaining: int = Field()
|
|
19
|
+
rate_limit_reset: int = Field()
|
|
20
|
+
twitter_response_tags: Optional[str] = Field()
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional
|
|
2
|
-
|
|
3
|
-
import twitter_openapi_python_generated as twitter
|
|
4
|
-
from pydantic import Field
|
|
5
|
-
|
|
6
|
-
from twitter_openapi_python.models import BaseModel
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class InitialStateApiUtilsRaw(BaseModel):
|
|
10
|
-
initial_state: Dict[str, Any] = Field()
|
|
11
|
-
meta_data: Dict[str, Any] = Field()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class InitialStateApiUtilsResponse(BaseModel):
|
|
15
|
-
raw: InitialStateApiUtilsRaw = Field()
|
|
16
|
-
user: Optional[twitter.UserLegacy] = Field(default=None)
|
|
17
|
-
session: Optional[twitter.Session] = Field(default=None)
|
|
1
|
+
from typing import Any, Dict, Optional
|
|
2
|
+
|
|
3
|
+
import twitter_openapi_python_generated as twitter
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from twitter_openapi_python.models import BaseModel
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class InitialStateApiUtilsRaw(BaseModel):
|
|
10
|
+
initial_state: Dict[str, Any] = Field()
|
|
11
|
+
meta_data: Dict[str, Any] = Field()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class InitialStateApiUtilsResponse(BaseModel):
|
|
15
|
+
raw: InitialStateApiUtilsRaw = Field()
|
|
16
|
+
user: Optional[twitter.UserLegacy] = Field(default=None)
|
|
17
|
+
session: Optional[twitter.Session] = Field(default=None)
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
from typing import Generic, TypeVar
|
|
2
|
-
|
|
3
|
-
import twitter_openapi_python_generated as twitter
|
|
4
|
-
from pydantic import Field
|
|
5
|
-
|
|
6
|
-
from twitter_openapi_python.models import ApiUtilsHeader, BaseModel
|
|
7
|
-
|
|
8
|
-
T1 = TypeVar("T1")
|
|
9
|
-
T2 = TypeVar("T2")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class TwitterApiUtilsRaw(BaseModel):
|
|
13
|
-
response: twitter.ApiResponse = Field()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class TwitterApiUtilsResponse(BaseModel, Generic[T1]):
|
|
17
|
-
raw: TwitterApiUtilsRaw = Field()
|
|
18
|
-
data: T1 = Field()
|
|
19
|
-
header: ApiUtilsHeader = Field()
|
|
1
|
+
from typing import Generic, TypeVar
|
|
2
|
+
|
|
3
|
+
import twitter_openapi_python_generated as twitter
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from twitter_openapi_python.models import ApiUtilsHeader, BaseModel
|
|
7
|
+
|
|
8
|
+
T1 = TypeVar("T1")
|
|
9
|
+
T2 = TypeVar("T2")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TwitterApiUtilsRaw(BaseModel):
|
|
13
|
+
response: twitter.ApiResponse = Field()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TwitterApiUtilsResponse(BaseModel, Generic[T1]):
|
|
17
|
+
raw: TwitterApiUtilsRaw = Field()
|
|
18
|
+
data: T1 = Field()
|
|
19
|
+
header: ApiUtilsHeader = Field()
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
from typing import Any, Generic, List, Optional, TypeVar
|
|
2
|
-
|
|
3
|
-
# from twitter_openapi_python_generated.api_response import ApiResponse
|
|
4
|
-
import twitter_openapi_python_generated.models as models
|
|
5
|
-
from pydantic import Field
|
|
6
|
-
|
|
7
|
-
from twitter_openapi_python.models import BaseModel
|
|
8
|
-
|
|
9
|
-
T = TypeVar("T")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class ApiUtilsRaw(BaseModel):
|
|
13
|
-
instruction: List[models.InstructionUnion] = Field(default_factory=list)
|
|
14
|
-
entry: List[models.TimelineAddEntry] = Field(default_factory=list)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class CursorApiUtilsResponse(BaseModel):
|
|
18
|
-
bottom: Optional[models.TimelineTimelineCursor] = Field(default=None)
|
|
19
|
-
top: Optional[models.TimelineTimelineCursor] = Field(default=None)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class TweetApiUtilsData(BaseModel):
|
|
23
|
-
raw: models.ItemResult = Field()
|
|
24
|
-
tweet: models.Tweet = Field()
|
|
25
|
-
user: models.User = Field()
|
|
26
|
-
replies: List["TweetApiUtilsData"] = Field(default_factory=list)
|
|
27
|
-
quoted: Optional["TweetApiUtilsData"] = Field(default=None)
|
|
28
|
-
retweeted: Optional["TweetApiUtilsData"] = Field(default=None)
|
|
29
|
-
promoted_metadata: Optional[dict[str, Any]] = Field(default=None)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class UserApiUtilsData(BaseModel):
|
|
33
|
-
raw: models.UserResults = Field()
|
|
34
|
-
user: models.User = Field()
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class TimelineApiUtilsResponse(BaseModel, Generic[T]):
|
|
38
|
-
raw: ApiUtilsRaw = Field()
|
|
39
|
-
cursor: CursorApiUtilsResponse = Field()
|
|
40
|
-
data: List[T] = Field(default_factory=list)
|
|
1
|
+
from typing import Any, Generic, List, Optional, TypeVar
|
|
2
|
+
|
|
3
|
+
# from twitter_openapi_python_generated.api_response import ApiResponse
|
|
4
|
+
import twitter_openapi_python_generated.models as models
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
7
|
+
from twitter_openapi_python.models import BaseModel
|
|
8
|
+
|
|
9
|
+
T = TypeVar("T")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ApiUtilsRaw(BaseModel):
|
|
13
|
+
instruction: List[models.InstructionUnion] = Field(default_factory=list)
|
|
14
|
+
entry: List[models.TimelineAddEntry] = Field(default_factory=list)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class CursorApiUtilsResponse(BaseModel):
|
|
18
|
+
bottom: Optional[models.TimelineTimelineCursor] = Field(default=None)
|
|
19
|
+
top: Optional[models.TimelineTimelineCursor] = Field(default=None)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TweetApiUtilsData(BaseModel):
|
|
23
|
+
raw: models.ItemResult = Field()
|
|
24
|
+
tweet: models.Tweet = Field()
|
|
25
|
+
user: models.User = Field()
|
|
26
|
+
replies: List["TweetApiUtilsData"] = Field(default_factory=list)
|
|
27
|
+
quoted: Optional["TweetApiUtilsData"] = Field(default=None)
|
|
28
|
+
retweeted: Optional["TweetApiUtilsData"] = Field(default=None)
|
|
29
|
+
promoted_metadata: Optional[dict[str, Any]] = Field(default=None)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UserApiUtilsData(BaseModel):
|
|
33
|
+
raw: models.UserResults = Field()
|
|
34
|
+
user: models.User = Field()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class TimelineApiUtilsResponse(BaseModel, Generic[T]):
|
|
38
|
+
raw: ApiUtilsRaw = Field()
|
|
39
|
+
cursor: CursorApiUtilsResponse = Field()
|
|
40
|
+
data: List[T] = Field(default_factory=list)
|
twitter_openapi_python/tid.py
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
from x_client_transaction
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import random
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
from x_client_transaction import ClientTransaction
|
|
5
|
+
from x_client_transaction.constants import ADDITIONAL_RANDOM_NUMBER, DEFAULT_KEYWORD
|
|
6
|
+
|
|
7
|
+
PAIR_URL = "https://raw.githubusercontent.com/fa0311/x-client-transaction-id-pair-dict/refs/heads/main/pair.json"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PairClientTransaction(ClientTransaction):
|
|
11
|
+
"""ClientTransaction built from a precomputed (verification, animationKey) pair.
|
|
12
|
+
|
|
13
|
+
The logged-out x.com shell no longer references ondemand.s, so the key material is
|
|
14
|
+
taken from https://github.com/fa0311/x-client-transaction-id-pair-dict instead.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, verification: str, animation_key: str):
|
|
18
|
+
self.random_keyword = DEFAULT_KEYWORD
|
|
19
|
+
self.random_number = ADDITIONAL_RANDOM_NUMBER
|
|
20
|
+
self.key = verification
|
|
21
|
+
self.key_bytes = self.get_key_bytes(key=verification)
|
|
22
|
+
self.animation_key = animation_key
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_tid(pair_url: str = PAIR_URL) -> ClientTransaction:
|
|
26
|
+
pair = random.choice(requests.get(pair_url).json())
|
|
27
|
+
return PairClientTransaction(verification=pair["verification"], animation_key=pair["animationKey"])
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
|
-
# flake8: noqa
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
from twitter_openapi_python.utils.api import (
|
|
7
|
-
build_cursor,
|
|
8
|
-
build_header,
|
|
9
|
-
build_response,
|
|
10
|
-
build_tweet_api_utils,
|
|
11
|
-
error_check,
|
|
12
|
-
entries_cursor,
|
|
13
|
-
get_kwargs,
|
|
14
|
-
get_legacy_kwargs,
|
|
15
|
-
instruction_to_entry,
|
|
16
|
-
tweet_entries_converter,
|
|
17
|
-
tweet_results_converter,
|
|
18
|
-
user_entries_converter,
|
|
19
|
-
user_or_null_converter,
|
|
20
|
-
user_result_converter,
|
|
21
|
-
non_nullable,
|
|
22
|
-
)
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from twitter_openapi_python.utils.api import (
|
|
7
|
+
build_cursor,
|
|
8
|
+
build_header,
|
|
9
|
+
build_response,
|
|
10
|
+
build_tweet_api_utils,
|
|
11
|
+
error_check,
|
|
12
|
+
entries_cursor,
|
|
13
|
+
get_kwargs,
|
|
14
|
+
get_legacy_kwargs,
|
|
15
|
+
instruction_to_entry,
|
|
16
|
+
tweet_entries_converter,
|
|
17
|
+
tweet_results_converter,
|
|
18
|
+
user_entries_converter,
|
|
19
|
+
user_or_null_converter,
|
|
20
|
+
user_result_converter,
|
|
21
|
+
non_nullable,
|
|
22
|
+
)
|