twitter-openapi-python 0.1.6__tar.gz → 0.1.8__tar.gz
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-0.1.6 → twitter_openapi_python-0.1.8}/PKG-INFO +7 -17
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/README.md +5 -15
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/pyproject.toml +2 -2
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/pyproject.toml.orig +2 -2
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/__init__.py +1 -0
- twitter_openapi_python-0.1.8/twitter_openapi_python/api/v20_post_api.py +53 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/client.py +5 -1
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/LICENSE +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/LICENSE.AGPL +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/__init__.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/birdwatch_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/community_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/default_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/initial_state_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/post_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/tweet_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/user_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/user_list_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/users_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/v11_get_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/v11_post_api.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/__init__.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/base.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/header.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/initial_state.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/response.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/timeline.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/py.typed +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/tid.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/utils/__init__.py +0 -0
- {twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/utils/api.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: twitter_openapi_python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Summary: Twitter OpenAPI
|
|
5
5
|
Keywords: twitter,api,python,scraper
|
|
6
6
|
Author: fa0311
|
|
@@ -8,7 +8,7 @@ Author-email: fa0311 <yuki@yuki0311.com>
|
|
|
8
8
|
License-Expression: LicenseRef-Custom OR AGPL-3.0-or-later
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
License-File: LICENSE.AGPL
|
|
11
|
-
Requires-Dist: twitter-openapi-python-generated==0.1.
|
|
11
|
+
Requires-Dist: twitter-openapi-python-generated==0.1.7
|
|
12
12
|
Requires-Dist: pydantic>=2.6
|
|
13
13
|
Requires-Dist: requests>=2.31.0,<3.0.0
|
|
14
14
|
Requires-Dist: urllib3>=2.1.0,<3.0.0
|
|
@@ -35,25 +35,15 @@ pip install twitter-openapi-python
|
|
|
35
35
|
import json
|
|
36
36
|
import datetime
|
|
37
37
|
|
|
38
|
-
from pathlib import Path
|
|
39
|
-
from tweepy_authlib import CookieSessionUserHandler
|
|
40
38
|
from twitter_openapi_python import TwitterOpenapiPython
|
|
41
39
|
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
cookies_dict = {k["name"]: k["value"] for k in cookies_dict}
|
|
48
|
-
else:
|
|
49
|
-
auth_handler = CookieSessionUserHandler(
|
|
50
|
-
screen_name=input("screen_name: "),
|
|
51
|
-
password=input("password: "),
|
|
52
|
-
)
|
|
53
|
-
cookies_dict = auth_handler.get_cookies().get_dict()
|
|
40
|
+
# cookies exported from the browser
|
|
41
|
+
with open("cookie.json", "r") as f:
|
|
42
|
+
cookies_dict = json.load(f)
|
|
43
|
+
if isinstance(cookies_dict, list):
|
|
44
|
+
cookies_dict = {k["name"]: k["value"] for k in cookies_dict}
|
|
54
45
|
|
|
55
46
|
# To extract cookies from Windows (Linux by default)
|
|
56
|
-
# If you use tweepy_authlib, you must be on Windows
|
|
57
47
|
client = TwitterOpenapiPython()
|
|
58
48
|
client.additional_api_headers = {
|
|
59
49
|
"sec-ch-ua-platform": '"Windows"',
|
|
@@ -16,25 +16,15 @@ pip install twitter-openapi-python
|
|
|
16
16
|
import json
|
|
17
17
|
import datetime
|
|
18
18
|
|
|
19
|
-
from pathlib import Path
|
|
20
|
-
from tweepy_authlib import CookieSessionUserHandler
|
|
21
19
|
from twitter_openapi_python import TwitterOpenapiPython
|
|
22
20
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
cookies_dict = {k["name"]: k["value"] for k in cookies_dict}
|
|
29
|
-
else:
|
|
30
|
-
auth_handler = CookieSessionUserHandler(
|
|
31
|
-
screen_name=input("screen_name: "),
|
|
32
|
-
password=input("password: "),
|
|
33
|
-
)
|
|
34
|
-
cookies_dict = auth_handler.get_cookies().get_dict()
|
|
21
|
+
# cookies exported from the browser
|
|
22
|
+
with open("cookie.json", "r") as f:
|
|
23
|
+
cookies_dict = json.load(f)
|
|
24
|
+
if isinstance(cookies_dict, list):
|
|
25
|
+
cookies_dict = {k["name"]: k["value"] for k in cookies_dict}
|
|
35
26
|
|
|
36
27
|
# To extract cookies from Windows (Linux by default)
|
|
37
|
-
# If you use tweepy_authlib, you must be on Windows
|
|
38
28
|
client = TwitterOpenapiPython()
|
|
39
29
|
client.additional_api_headers = {
|
|
40
30
|
"sec-ch-ua-platform": '"Windows"',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "twitter_openapi_python"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "Twitter OpenAPI"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "LicenseRef-Custom OR AGPL-3.0-or-later"
|
|
@@ -16,7 +16,7 @@ keywords = [
|
|
|
16
16
|
]
|
|
17
17
|
requires-python = ">=3.10"
|
|
18
18
|
dependencies = [
|
|
19
|
-
"twitter_openapi_python_generated==0.1.
|
|
19
|
+
"twitter_openapi_python_generated==0.1.7",
|
|
20
20
|
"pydantic>=2.6",
|
|
21
21
|
"requests>=2.31.0,<3.0.0",
|
|
22
22
|
"urllib3>=2.1.0,<3.0.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "twitter_openapi_python"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "Twitter OpenAPI"
|
|
5
5
|
authors = [{ name = "fa0311", email = "yuki@yuki0311.com" }]
|
|
6
6
|
readme = "README.md"
|
|
@@ -9,7 +9,7 @@ license-files = ["LICENSE", "LICENSE.AGPL"]
|
|
|
9
9
|
keywords = ["twitter", "api", "python", "scraper"]
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
dependencies = [
|
|
12
|
-
"twitter_openapi_python_generated==0.1.
|
|
12
|
+
"twitter_openapi_python_generated==0.1.7",
|
|
13
13
|
"pydantic>=2.6",
|
|
14
14
|
"requests>=2.31.0,<3.0.0",
|
|
15
15
|
"urllib3>=2.1.0,<3.0.0",
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/__init__.py
RENAMED
|
@@ -13,3 +13,4 @@ from twitter_openapi_python.api.user_list_api import UserListApiUtils
|
|
|
13
13
|
from twitter_openapi_python.api.users_api import UsersApiUtils
|
|
14
14
|
from twitter_openapi_python.api.v11_get_api import V11GetApiUtils
|
|
15
15
|
from twitter_openapi_python.api.v11_post_api import V11PostApiUtils
|
|
16
|
+
from twitter_openapi_python.api.v20_post_api import V20PostApiUtils
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from typing import Any, Callable, Optional, TypeVar
|
|
2
|
+
|
|
3
|
+
import twitter_openapi_python_generated as twitter
|
|
4
|
+
|
|
5
|
+
from twitter_openapi_python.models import TwitterApiUtilsResponse
|
|
6
|
+
from twitter_openapi_python.utils import build_response, get_legacy_kwargs
|
|
7
|
+
|
|
8
|
+
T = TypeVar("T")
|
|
9
|
+
ApiFnType = Callable[..., twitter.ApiResponse[T]]
|
|
10
|
+
ParamType = dict[str, Any]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class V20PostApiUtils:
|
|
14
|
+
api: twitter.V20PostApi
|
|
15
|
+
flag: ParamType
|
|
16
|
+
|
|
17
|
+
def __init__(self, api: twitter.V20PostApi, flag: ParamType):
|
|
18
|
+
self.api = api
|
|
19
|
+
self.flag = flag
|
|
20
|
+
|
|
21
|
+
def request(
|
|
22
|
+
self,
|
|
23
|
+
apiFn: "ApiFnType[T]",
|
|
24
|
+
key: str,
|
|
25
|
+
param: ParamType,
|
|
26
|
+
) -> TwitterApiUtilsResponse[T]:
|
|
27
|
+
args = get_legacy_kwargs(flag=self.flag[key], additional=param)
|
|
28
|
+
res = apiFn(**args)
|
|
29
|
+
return build_response(response=res, data=res.data)
|
|
30
|
+
|
|
31
|
+
def post_timeline_feedback(
|
|
32
|
+
self,
|
|
33
|
+
feedback_type: str,
|
|
34
|
+
action_metadata: str,
|
|
35
|
+
undo: bool = False,
|
|
36
|
+
extra_param: Optional[ParamType] = None,
|
|
37
|
+
) -> TwitterApiUtilsResponse[None]:
|
|
38
|
+
"""feedback_type and action_metadata are the query of a feedbackUrl in the timeline."""
|
|
39
|
+
param = {
|
|
40
|
+
"feedback_type": feedback_type,
|
|
41
|
+
"action_metadata": action_metadata,
|
|
42
|
+
"feedback_type2": feedback_type, # the form repeats the query's feedback_type
|
|
43
|
+
"undo": "true" if undo else "false",
|
|
44
|
+
}
|
|
45
|
+
if extra_param is not None:
|
|
46
|
+
param.update(extra_param)
|
|
47
|
+
|
|
48
|
+
response = self.request(
|
|
49
|
+
apiFn=self.api.post_timeline_feedback_with_http_info,
|
|
50
|
+
param=param,
|
|
51
|
+
key="timeline/feedback.json",
|
|
52
|
+
)
|
|
53
|
+
return response
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/client.py
RENAMED
|
@@ -19,6 +19,7 @@ from twitter_openapi_python.api import (
|
|
|
19
19
|
UsersApiUtils,
|
|
20
20
|
V11GetApiUtils,
|
|
21
21
|
V11PostApiUtils,
|
|
22
|
+
V20PostApiUtils,
|
|
22
23
|
)
|
|
23
24
|
from twitter_openapi_python.tid import get_tid
|
|
24
25
|
|
|
@@ -67,9 +68,12 @@ class TwitterOpenapiPythonClient:
|
|
|
67
68
|
def get_v11_post_api(self) -> V11PostApiUtils:
|
|
68
69
|
return V11PostApiUtils(twitter.V11PostApi(self.api), self.placeholder)
|
|
69
70
|
|
|
71
|
+
def get_v20_post_api(self) -> V20PostApiUtils:
|
|
72
|
+
return V20PostApiUtils(twitter.V20PostApi(self.api), self.placeholder)
|
|
73
|
+
|
|
70
74
|
|
|
71
75
|
class TwitterOpenapiPython:
|
|
72
|
-
hash: str = "
|
|
76
|
+
hash: str = "6c4914f799402a927ec02727686032443fe6ffe9"
|
|
73
77
|
placeholder_url = "https://raw.githubusercontent.com/fa0311/twitter-openapi/{hash}/src/config/placeholder.json"
|
|
74
78
|
header = "https://raw.githubusercontent.com/fa0311/latest-user-agent/refs/heads/main/header.json"
|
|
75
79
|
access_token: str = (
|
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/post_api.py
RENAMED
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/api/user_api.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/models/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.1.6 → twitter_openapi_python-0.1.8}/twitter_openapi_python/utils/api.py
RENAMED
|
File without changes
|