Skip to content

Commit

Permalink
fix: Fix format of secret in params
Browse files Browse the repository at this point in the history
Co-authored-by: pythonwood <[email protected]>
  • Loading branch information
pawamoy and pythonwood committed Feb 20, 2019
1 parent 57287fb commit e01fd9c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/aria2p/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ def call(self, method, params=None, msg_id=None, insert_secret=True):

if insert_secret and self.secret:
if method.startswith("aria2."):
params.insert(0, self.secret)
params.insert(0, f"token:{self.secret}")
elif method == self.MULTICALL:
for param in params[0]:
param["params"].insert(0, self.secret)
param["params"].insert(0, f"token:{self.secret}")

return self.res_or_raise(self.post(self.get_payload(method, params, msg_id=msg_id)))

Expand Down Expand Up @@ -219,7 +219,7 @@ def batch_call(self, calls, insert_secret=True):
for method, params, msg_id in calls:
params = self.get_params(*params)
if insert_secret and self.secret and method.startswith("aria2."):
params.insert(0, self.secret)
params.insert(0, f"token:{self.secret}")
payloads.append(self.get_payload(method, params, msg_id, as_json=False))

payload = json.dumps(payloads)
Expand Down Expand Up @@ -265,7 +265,7 @@ def multicall2(self, calls, insert_secret=True):
for method, params in calls:
params = self.get_params(*params)
if insert_secret and self.secret and method.startswith("aria2."):
params.insert(0, self.secret)
params.insert(0, f"token:{self.secret}")
multicall_params.append({"methodName": method, "params": params})

payload = self.get_payload(self.MULTICALL, [multicall_params])
Expand Down

0 comments on commit e01fd9c

Please sign in to comment.