Skip to content

Commit 2e276ea

Browse files
committed
feat(media): ✨ update api for media upload v2
1 parent 8d4cca7 commit 2e276ea

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

pytwitter/api.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ def upload_media_chunked_init_v2(
855855
"""
856856

857857
args = {
858-
"command": "INIT",
859858
"total_bytes": total_bytes,
860859
"media_type": media_type,
861860
}
@@ -867,9 +866,9 @@ def upload_media_chunked_init_v2(
867866
)
868867

869868
resp = self._request(
870-
url=f"{self.BASE_URL_V2}/media/upload",
869+
url=f"{self.BASE_URL_V2}/media/upload/initialize",
871870
verb="POST",
872-
data=args,
871+
json=args,
873872
)
874873
data = self._parse_response(resp=resp)
875874
if return_json:
@@ -893,13 +892,9 @@ def upload_media_chunked_append_v2(
893892
:return: True if upload success.
894893
"""
895894
resp = self._request(
896-
url=f"{self.BASE_URL_V2}/media/upload",
895+
url=f"{self.BASE_URL_V2}/media/upload/{media_id}/append",
897896
verb="POST",
898-
params={
899-
"command": "APPEND",
900-
"media_id": media_id,
901-
},
902-
data={"segment_index": segment_index},
897+
json={"segment_index": segment_index},
903898
files={"media": media},
904899
)
905900
if resp.ok:
@@ -921,12 +916,8 @@ def upload_media_chunked_finalize_v2(
921916
:return: Media upload response.
922917
"""
923918
resp = self._request(
924-
url=f"{self.BASE_URL_V2}/media/upload",
919+
url=f"{self.BASE_URL_V2}/media/upload/{media_id}/finalize",
925920
verb="POST",
926-
params={
927-
"command": "FINALIZE",
928-
"media_id": media_id,
929-
},
930921
)
931922
data = self._parse_response(resp=resp)
932923
if return_json:

0 commit comments

Comments
 (0)