added get_quota() and get_balance()

This commit is contained in:
richard 2013-03-10 03:38:22 +00:00
parent 8f064350fd
commit 83b1de1662
2 changed files with 22 additions and 2 deletions

View file

@ -279,6 +279,22 @@ class Mega(object):
node_id = i['h']
return node_id
def get_quota(self):
'''
Get current remaining disk quota in MegaBytes
'''
json_resp = self.api_request({'a': 'uq', 'xfer': 1})
#convert bytes to megabyes
return json_resp['mstrg']/1048576
def get_balance(self):
'''
Get account monetary balance, Pro accounts only
'''
user_data = self.api_request({"a":"uq","pro":1})
if 'balance' in user_data:
return user_data['balance']
##########################################################################
# DELETE
def delete(self, public_handle):

View file

@ -2,8 +2,8 @@ from mega import Mega
def test():
#user details
email = 'your@email.com'
password = 'password'
email = 'richard@richard.do'
password = 'fofput2'
mega = Mega()
@ -17,6 +17,9 @@ def test():
#get account files
files = m.get_files()
#get account disk quota in MB
print(m.get_quota())
#example iterate over files
for file in files:
print(files[file])
@ -27,6 +30,7 @@ def test():
#search for a file in account
file = m.find('tests.py')
if file:
#get public link
link = m.get_link(file)