twitter-openapi-python 0.0.25__py3-none-any.whl → 0.0.26__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/client.py +9 -3
- {twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/METADATA +16 -5
- {twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/RECORD +7 -7
- {twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/LICENSE +0 -0
- {twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/LICENSE.AGPL +0 -0
- {twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/WHEEL +0 -0
- {twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/top_level.txt +0 -0
twitter_openapi_python/client.py
CHANGED
|
@@ -58,7 +58,7 @@ class TwitterOpenapiPythonClient:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
class TwitterOpenapiPython:
|
|
61
|
-
hash: str = "
|
|
61
|
+
hash: str = "4b27150977e1bdd807de8969dc0ddd7918ac9923"
|
|
62
62
|
placeholder_url = "https://raw.githubusercontent.com/fa0311/twitter-openapi/{hash}/src/config/placeholder.json"
|
|
63
63
|
header = "https://raw.githubusercontent.com/fa0311/latest-user-agent/refs/heads/main/header.json"
|
|
64
64
|
access_token: str = "AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA"
|
|
@@ -81,7 +81,6 @@ class TwitterOpenapiPython:
|
|
|
81
81
|
{
|
|
82
82
|
**getHader("chrome-fetch"),
|
|
83
83
|
"accept-encoding": "identity",
|
|
84
|
-
"pragma": "no-cache",
|
|
85
84
|
"referer": self.twitter_url,
|
|
86
85
|
"priority": "u=1, i",
|
|
87
86
|
"x-twitter-client-language": "en",
|
|
@@ -98,11 +97,18 @@ class TwitterOpenapiPython:
|
|
|
98
97
|
},
|
|
99
98
|
)
|
|
100
99
|
|
|
100
|
+
def remove_prefix(self, text: str) -> str:
|
|
101
|
+
if text.startswith("x-twitter-"):
|
|
102
|
+
return text[10:]
|
|
103
|
+
if text.startswith("x-"):
|
|
104
|
+
return text[2:]
|
|
105
|
+
return text
|
|
106
|
+
|
|
101
107
|
def kebab_to_upper_camel(self, text: dict[str, Any]) -> dict[str, Any]:
|
|
102
108
|
res = {}
|
|
103
109
|
for key, value in text.items():
|
|
104
110
|
new_key = "".join(
|
|
105
|
-
[x.capitalize() for x in
|
|
111
|
+
[x.capitalize() for x in self.remove_prefix(key).split("-")]
|
|
106
112
|
)
|
|
107
113
|
res[new_key] = value
|
|
108
114
|
return res
|
{twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: twitter-openapi-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.26
|
|
4
4
|
Summary: Twitter OpenAPI
|
|
5
5
|
Home-page: https://github.com/fa0311/twitter_openapi_python
|
|
6
6
|
Author: fa0311
|
|
@@ -10,7 +10,7 @@ Keywords: OpenAPI,OpenAPI-Generator,Twitter OpenAPI
|
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
12
|
License-File: LICENSE.AGPL
|
|
13
|
-
Requires-Dist: twitter-openapi-python-generated ==0.0.
|
|
13
|
+
Requires-Dist: twitter-openapi-python-generated ==0.0.24
|
|
14
14
|
Requires-Dist: pydantic >=2.6
|
|
15
15
|
|
|
16
16
|
# twitter_openapi_python
|
|
@@ -48,8 +48,18 @@ else:
|
|
|
48
48
|
)
|
|
49
49
|
cookies_dict = auth_handler.get_cookies().get_dict()
|
|
50
50
|
|
|
51
|
+
# To extract cookies from Windows (Linux by default)
|
|
52
|
+
# If you use tweepy_authlib, you must be on Windows
|
|
53
|
+
client = TwitterOpenapiPython()
|
|
54
|
+
client.additional_api_headers = {
|
|
55
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
56
|
+
}
|
|
57
|
+
client.additional_browser_headers = {
|
|
58
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
59
|
+
}
|
|
60
|
+
|
|
51
61
|
# get client from cookies
|
|
52
|
-
撫 =
|
|
62
|
+
撫 = client.get_client_from_cookies(cookies=cookies_dict)
|
|
53
63
|
|
|
54
64
|
# tweet "Hello World!!" with current time
|
|
55
65
|
time = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
@@ -79,8 +89,9 @@ In other words, if the sec-ch-ua-platform does not match, the Token cannot be us
|
|
|
79
89
|
This library uses the Linux Chrome header by default.
|
|
80
90
|
To use Token issued by Windows, do the following.
|
|
81
91
|
|
|
82
|
-
```
|
|
83
|
-
|
|
92
|
+
```python
|
|
93
|
+
client = TwitterOpenapiPython()
|
|
94
|
+
client.additional_api_headers = {
|
|
84
95
|
"sec-ch-ua-platform": '"Windows"',
|
|
85
96
|
};
|
|
86
97
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
twitter_openapi_python/__init__.py,sha256=stqYIfWDqM0yC93SQNp4-b2hSz-ONWR3QxOG5g2oREg,339
|
|
2
|
-
twitter_openapi_python/client.py,sha256=
|
|
2
|
+
twitter_openapi_python/client.py,sha256=zs95e9BLmYLMfO5ZF3XqrSlj2wMBCeOHsYALtBNd8fQ,6836
|
|
3
3
|
twitter_openapi_python/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
twitter_openapi_python/api/__init__.py,sha256=-2hoS75Fp0KvCIWKYQFpvAl0pcbFyt7Be3ood08P7n8,643
|
|
5
5
|
twitter_openapi_python/api/default_api.py,sha256=PeHYaAw6xaUB9ZE3An5SKcEvW71JLTFSgyte80BBvX4,2751
|
|
@@ -19,9 +19,9 @@ twitter_openapi_python/models/response.py,sha256=ZuaX36mKRsVx5aiJhNw3CjrvVGVaGjM
|
|
|
19
19
|
twitter_openapi_python/models/timeline.py,sha256=AoWfrJsonYImlweciaUSjFzmeciaX0zshi7d-FkT4LM,1392
|
|
20
20
|
twitter_openapi_python/utils/__init__.py,sha256=QVT1eCClP9EVfcZ4QU96TVegfAUDEtJ-PVp3zv6qy6w,449
|
|
21
21
|
twitter_openapi_python/utils/api.py,sha256=JTSXE1Wh3AiuOb_APTDTQMrR4HTkI9AihzrXkJGV2d8,10026
|
|
22
|
-
twitter_openapi_python-0.0.
|
|
23
|
-
twitter_openapi_python-0.0.
|
|
24
|
-
twitter_openapi_python-0.0.
|
|
25
|
-
twitter_openapi_python-0.0.
|
|
26
|
-
twitter_openapi_python-0.0.
|
|
27
|
-
twitter_openapi_python-0.0.
|
|
22
|
+
twitter_openapi_python-0.0.26.dist-info/LICENSE,sha256=xthyYzrtSmRlBu2gnfuIxzsZeHrqtIZgZPL9UPrYiQU,1524
|
|
23
|
+
twitter_openapi_python-0.0.26.dist-info/LICENSE.AGPL,sha256=Nv6u1ubULm-E2y6q2-pQPK8s2BzkOltLaVlPKQ3tkcs,35182
|
|
24
|
+
twitter_openapi_python-0.0.26.dist-info/METADATA,sha256=R9x-5XSeTj8csBZpxiaaXPDyf5rG1ihqmltoCT7PkWw,3070
|
|
25
|
+
twitter_openapi_python-0.0.26.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
26
|
+
twitter_openapi_python-0.0.26.dist-info/top_level.txt,sha256=wKFCnW_S6aWD3nFPmd65SxZIviiqQ30LqHOLLpcnTdE,23
|
|
27
|
+
twitter_openapi_python-0.0.26.dist-info/RECORD,,
|
|
File without changes
|
{twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/LICENSE.AGPL
RENAMED
|
File without changes
|
|
File without changes
|
{twitter_openapi_python-0.0.25.dist-info → twitter_openapi_python-0.0.26.dist-info}/top_level.txt
RENAMED
|
File without changes
|