Add argument params to _api_request for custom parameters.

This commit is contained in:
Ethan Dalool 2020-03-23 19:26:24 -07:00
parent 634a977a99
commit 13595f724a

View file

@ -46,12 +46,14 @@ class Mega:
retry=retry_if_exception_type(RuntimeError),
wait=wait_exponential(multiplier=2, min=2, max=60)
)
def _api_request(self, data):
params = {'id': self.sequence_num}
def _api_request(self, data, params={}):
req_params = {'id': self.sequence_num}
self.sequence_num += 1
if self.sid:
params.update({'sid': self.sid})
req_params.update({'sid': self.sid})
req_params.update(params)
# ensure input data is a list
if not isinstance(data, list):
@ -60,7 +62,7 @@ class Mega:
url = f'{self.schema}://g.api.{self.domain}/cs'
req = requests.post(
url,
params=params,
params=req_params,
data=json.dumps(data),
timeout=self.timeout,
)