Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions transferwee.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ def _storm_prepare(authorization: str, filenames: List[str]) -> dict[Any, Any]:

Return the parsed JSON response.
"""
j = {
"blocks": [_storm_prepare_item(f) for f in filenames],
}
requests.options(
_storm_urls(authorization)["WETRANSFER_STORM_BLOCK"],
headers={
Expand All @@ -381,16 +378,27 @@ def _storm_prepare(authorization: str, filenames: List[str]) -> dict[Any, Any]:
"User-Agent": WETRANSFER_USER_AGENT,
},
)
r = requests.post(
_storm_urls(authorization)["WETRANSFER_STORM_BLOCK"],
json=j,
headers={
"Authorization": f"Bearer {authorization}",
"Origin": "https://wetransfer.com",
"User-Agent": WETRANSFER_USER_AGENT,
},
)
return r.json()

response = {"ok":True, "data":{"blocks":[]}}
chunk_size = 100
for i in range(0, len(filenames), chunk_size):
j = {
"blocks": [_storm_prepare_item(f) for f in filenames[i:i+chunk_size]],
}
r = requests.post(
_storm_urls(authorization)["WETRANSFER_STORM_BLOCK"],
json=j,
headers={
"Authorization": f"Bearer {authorization}",
"Origin": "https://wetransfer.com",
"User-Agent": WETRANSFER_USER_AGENT,
},
)

response["ok"] = response["ok"] and r.json()["ok"]
response["data"]["blocks"] += r.json()["data"]["blocks"]

return response


def _storm_finalize_item(
Expand Down