Add argument params to _api_request for custom parameters.
This commit is contained in:
parent
634a977a99
commit
13595f724a
1 changed files with 6 additions and 4 deletions
|
@ -46,12 +46,14 @@ class Mega:
|
||||||
retry=retry_if_exception_type(RuntimeError),
|
retry=retry_if_exception_type(RuntimeError),
|
||||||
wait=wait_exponential(multiplier=2, min=2, max=60)
|
wait=wait_exponential(multiplier=2, min=2, max=60)
|
||||||
)
|
)
|
||||||
def _api_request(self, data):
|
def _api_request(self, data, params={}):
|
||||||
params = {'id': self.sequence_num}
|
req_params = {'id': self.sequence_num}
|
||||||
self.sequence_num += 1
|
self.sequence_num += 1
|
||||||
|
|
||||||
if self.sid:
|
if self.sid:
|
||||||
params.update({'sid': self.sid})
|
req_params.update({'sid': self.sid})
|
||||||
|
|
||||||
|
req_params.update(params)
|
||||||
|
|
||||||
# ensure input data is a list
|
# ensure input data is a list
|
||||||
if not isinstance(data, list):
|
if not isinstance(data, list):
|
||||||
|
@ -60,7 +62,7 @@ class Mega:
|
||||||
url = f'{self.schema}://g.api.{self.domain}/cs'
|
url = f'{self.schema}://g.api.{self.domain}/cs'
|
||||||
req = requests.post(
|
req = requests.post(
|
||||||
url,
|
url,
|
||||||
params=params,
|
params=req_params,
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
timeout=self.timeout,
|
timeout=self.timeout,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue