twitter-openapi-python 0.0.9__tar.gz → 0.0.12__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.
Files changed (33) hide show
  1. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/PKG-INFO +1 -1
  2. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/pyproject.toml +2 -2
  3. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/setup.py +1 -1
  4. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/client.py +23 -6
  5. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python.egg-info/PKG-INFO +1 -1
  6. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/LICENSE +0 -0
  7. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/LICENSE.AGPL +0 -0
  8. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/README.md +0 -0
  9. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/setup.cfg +0 -0
  10. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/__init__.py +0 -0
  11. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/__init__.py +0 -0
  12. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/default_api.py +0 -0
  13. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/initial_state_api.py +0 -0
  14. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/post_api.py +0 -0
  15. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/tweet_api.py +0 -0
  16. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/user_api.py +0 -0
  17. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/user_list_api.py +0 -0
  18. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/users_api.py +0 -0
  19. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/v11_get_api.py +0 -0
  20. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/api/v11_post_api.py +0 -0
  21. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/models/__init__.py +0 -0
  22. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/models/base.py +0 -0
  23. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/models/header.py +0 -0
  24. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/models/initial_state.py +0 -0
  25. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/models/response.py +0 -0
  26. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/models/timeline.py +0 -0
  27. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/py.typed +0 -0
  28. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/utils/__init__.py +0 -0
  29. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python/utils/api.py +0 -0
  30. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python.egg-info/SOURCES.txt +0 -0
  31. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python.egg-info/dependency_links.txt +0 -0
  32. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python.egg-info/requires.txt +0 -0
  33. {twitter_openapi_python-0.0.9 → twitter_openapi_python-0.0.12}/twitter_openapi_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: twitter_openapi_python
3
- Version: 0.0.9
3
+ Version: 0.0.12
4
4
  Summary: Twitter OpenAPI
5
5
  Home-page: https://github.com/fa0311/twitter_openapi_python
6
6
  Author: fa0311
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "twitter_openapi_python"
3
- version = "0.0.9"
3
+ version = "0.0.12"
4
4
  description = "Twitter OpenAPI"
5
5
  authors = ["fa0311 <yuki@yuki0311.com>"]
6
6
  license = "proprietary" # or "AGPL-3.0-only"
@@ -14,7 +14,7 @@ include = ["twitter_openapi_python/py.typed"]
14
14
  python = "^3.7"
15
15
  pydantic = "^1.10.5, <2"
16
16
 
17
- twitter-openapi-python-generated = "0.0.6"
17
+ twitter-openapi-python-generated = "0.0.7"
18
18
 
19
19
  [tool.poetry.dev-dependencies]
20
20
 
@@ -3,7 +3,7 @@
3
3
  from setuptools import find_packages, setup
4
4
 
5
5
  NAME = "twitter_openapi_python"
6
- VERSION = "0.0.9"
6
+ VERSION = "0.0.12"
7
7
  PYTHON_REQUIRES = ">=3.7"
8
8
  REQUIRES = [
9
9
  "twitter_openapi_python_generated == 0.0.6",
@@ -1,4 +1,4 @@
1
- import random
1
+ import json
2
2
  import re
3
3
  from typing import Any
4
4
 
@@ -120,12 +120,10 @@ class TwitterOpenapiPython:
120
120
 
121
121
  if cookies.get("ct0"):
122
122
  api_key.update({"AuthType": "OAuth2Session"})
123
- ct0 = cookies.get("ct0", "".join(random.choices("0123456789abcdef", k=32)))
124
- api_key.update({"CsrfToken": ct0})
123
+ api_key.update({"CsrfToken": cookies["ct0"]})
125
124
 
126
- gt = cookies.get("gt")
127
- if gt is not None:
128
- api_key.update({"GuestToken": gt})
125
+ if cookies.get("gt"):
126
+ api_key.update({"GuestToken": cookies["gt"]})
129
127
 
130
128
  api_conf = conf.Configuration(api_key=api_key)
131
129
  api_conf.access_token = self.access_token
@@ -157,4 +155,23 @@ class TwitterOpenapiPython:
157
155
 
158
156
  find = re.findall(r'document.cookie="(.*?)";', res_2.data.decode())
159
157
  session.update(self.cookie_normalize(find))
158
+
159
+ session.pop("ct0")
160
+
161
+ if not session.get("gt"):
162
+ activate_header = self.browser_headers | {
163
+ "authorization": "Bearer {}".format(self.access_token),
164
+ "x-twitter-active-user": "yes",
165
+ "x-twitter-client-language": "en",
166
+ }
167
+ res_3 = http.request(
168
+ "POST",
169
+ "https://api.twitter.com/1.1/guest/activate.json",
170
+ headers=activate_header | {"Cookie": self.cookie_to_str(session)},
171
+ )
172
+ gt = json.loads(res_3.data.decode())["guest_token"]
173
+ session.update({"gt": gt})
174
+
175
+ # ct0 = cookies.get("ct0", "".join(random.choices("0123456789abcdef", k=32)))
176
+
160
177
  return self.get_client_from_cookies(session)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: twitter-openapi-python
3
- Version: 0.0.9
3
+ Version: 0.0.12
4
4
  Summary: Twitter OpenAPI
5
5
  Home-page: https://github.com/fa0311/twitter_openapi_python
6
6
  Author: fa0311