twitter-openapi-python 0.0.13__tar.gz → 0.0.15__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.13 → twitter_openapi_python-0.0.15}/PKG-INFO +1 -1
  2. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/pyproject.toml +2 -2
  3. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/setup.py +1 -1
  4. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/client.py +2 -2
  5. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/utils/api.py +39 -14
  6. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python.egg-info/PKG-INFO +1 -1
  7. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/LICENSE +0 -0
  8. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/LICENSE.AGPL +0 -0
  9. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/README.md +0 -0
  10. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/setup.cfg +0 -0
  11. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/__init__.py +0 -0
  12. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/__init__.py +0 -0
  13. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/default_api.py +0 -0
  14. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/initial_state_api.py +0 -0
  15. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/post_api.py +0 -0
  16. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/tweet_api.py +0 -0
  17. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/user_api.py +0 -0
  18. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/user_list_api.py +0 -0
  19. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/users_api.py +0 -0
  20. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/v11_get_api.py +0 -0
  21. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/api/v11_post_api.py +0 -0
  22. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/models/__init__.py +0 -0
  23. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/models/base.py +0 -0
  24. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/models/header.py +0 -0
  25. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/models/initial_state.py +0 -0
  26. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/models/response.py +0 -0
  27. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/models/timeline.py +0 -0
  28. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/py.typed +0 -0
  29. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python/utils/__init__.py +0 -0
  30. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python.egg-info/SOURCES.txt +0 -0
  31. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python.egg-info/dependency_links.txt +0 -0
  32. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/twitter_openapi_python.egg-info/requires.txt +0 -0
  33. {twitter_openapi_python-0.0.13 → twitter_openapi_python-0.0.15}/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.13
3
+ Version: 0.0.15
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.13"
3
+ version = "0.0.15"
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 = ">=2.6"
16
16
 
17
- twitter-openapi-python-generated = "0.0.9"
17
+ twitter-openapi-python-generated = "0.0.11"
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.13"
6
+ VERSION = "0.0.15"
7
7
  PYTHON_REQUIRES = ">=3.7"
8
8
  REQUIRES = [
9
9
  "twitter_openapi_python_generated == 0.0.9",
@@ -110,8 +110,8 @@ class TwitterOpenapiPython:
110
110
  api: twitter.ApiClient,
111
111
  ) -> TwitterOpenapiPythonClient:
112
112
  http = urllib3.PoolManager()
113
- flag = http.request("GET", self.placeholder_url.format(hash=self.hash)).json()
114
- return TwitterOpenapiPythonClient(api, flag)
113
+ flag = http.request("GET", self.placeholder_url.format(hash=self.hash))
114
+ return TwitterOpenapiPythonClient(api, json.loads(flag.data))
115
115
 
116
116
  def get_client_from_cookies(
117
117
  self,
@@ -1,5 +1,5 @@
1
1
  import json
2
- from typing import Any, Dict, List, Optional, TypeGuard, TypeVar
2
+ from typing import Any, Dict, List, Mapping, Optional, TypeGuard, TypeVar
3
3
 
4
4
  import twitter_openapi_python_generated as twitter
5
5
  import twitter_openapi_python_generated.models as models
@@ -83,35 +83,55 @@ def instruction_to_entry(
83
83
  def tweet_entries_converter(
84
84
  input: List[models.TimelineAddEntry],
85
85
  ) -> List[TweetApiUtilsData]:
86
- def map_fn(x: models.TimelineAddEntry) -> Optional[TweetApiUtilsData]:
86
+ def map_fn(x: models.TimelineAddEntry) -> Optional[List[TweetApiUtilsData]]:
87
87
  one_of = x.content.actual_instance
88
88
 
89
89
  if isinstance(one_of, models.TimelineTimelineItem):
90
90
  item = one_of.item_content.actual_instance
91
91
  if isinstance(item, models.TimelineTweet):
92
- return build_tweet_api_utils(
93
- result=item.tweet_results,
94
- promoted_metadata=item.promoted_metadata,
95
- reply=[],
92
+ return non_nullable_list(
93
+ [
94
+ build_tweet_api_utils(
95
+ result=item.tweet_results,
96
+ promoted_metadata=item.promoted_metadata,
97
+ reply=[],
98
+ )
99
+ ]
96
100
  )
97
101
  elif isinstance(one_of, models.TimelineTimelineModule):
98
102
  module = one_of.items or []
99
103
  timelineList = non_nullable_list(list(map(map_fn_2, module)))
100
104
  if len(timelineList) == 0:
101
105
  return None
102
- timeline = timelineList[0]
103
- return build_tweet_api_utils(
104
- result=timeline.tweet_results,
105
- promoted_metadata=timeline.promoted_metadata,
106
- reply=timelineList[1:],
107
- )
106
+ if one_of.display_type == models.DisplayType.VERTICALGRID:
107
+ return non_nullable_list(
108
+ [
109
+ build_tweet_api_utils(
110
+ result=x.tweet_results,
111
+ promoted_metadata=x.promoted_metadata,
112
+ reply=[],
113
+ )
114
+ for x in timelineList
115
+ ]
116
+ )
117
+ else:
118
+ timeline = timelineList[0]
119
+ return non_nullable_list(
120
+ [
121
+ build_tweet_api_utils(
122
+ result=timeline.tweet_results,
123
+ promoted_metadata=timeline.promoted_metadata,
124
+ reply=timelineList[1:],
125
+ )
126
+ ]
127
+ )
108
128
 
109
129
  def map_fn_2(x: models.ModuleItem) -> Optional[models.TimelineTweet]:
110
130
  item = x.item.item_content.actual_instance
111
131
  if isinstance(item, models.TimelineTweet):
112
132
  return item
113
133
 
114
- return non_nullable_list(list(map(map_fn, input)))
134
+ return flat(non_nullable_list(list(map(map_fn, input))))
115
135
 
116
136
 
117
137
  def user_or_null_converter(user: models.UserUnion) -> Optional[models.User]:
@@ -245,7 +265,12 @@ def build_response(
245
265
  if response.headers is None:
246
266
  raise Exception("headers is None")
247
267
 
248
- header = build_header(response.headers)
268
+ if isinstance(response.headers, Dict):
269
+ header = build_header(response.headers)
270
+ elif isinstance(response.headers, Mapping):
271
+ header = build_header(dict(response.headers))
272
+ else:
273
+ raise Exception("headers is not a dict")
249
274
 
250
275
  return TwitterApiUtilsResponse(
251
276
  raw=TwitterApiUtilsRaw(response=response),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: twitter-openapi-python
3
- Version: 0.0.13
3
+ Version: 0.0.15
4
4
  Summary: Twitter OpenAPI
5
5
  Home-page: https://github.com/fa0311/twitter_openapi_python
6
6
  Author: fa0311