added get_quota() and get_balance()
This commit is contained in:
parent
8f064350fd
commit
83b1de1662
2 changed files with 22 additions and 2 deletions
16
mega/mega.py
16
mega/mega.py
|
@ -279,6 +279,22 @@ class Mega(object):
|
||||||
node_id = i['h']
|
node_id = i['h']
|
||||||
return node_id
|
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
|
# DELETE
|
||||||
def delete(self, public_handle):
|
def delete(self, public_handle):
|
||||||
|
|
8
tests.py
8
tests.py
|
@ -2,8 +2,8 @@ from mega import Mega
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
#user details
|
#user details
|
||||||
email = 'your@email.com'
|
email = 'richard@richard.do'
|
||||||
password = 'password'
|
password = 'fofput2'
|
||||||
|
|
||||||
mega = Mega()
|
mega = Mega()
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ def test():
|
||||||
#get account files
|
#get account files
|
||||||
files = m.get_files()
|
files = m.get_files()
|
||||||
|
|
||||||
|
#get account disk quota in MB
|
||||||
|
print(m.get_quota())
|
||||||
|
|
||||||
#example iterate over files
|
#example iterate over files
|
||||||
for file in files:
|
for file in files:
|
||||||
print(files[file])
|
print(files[file])
|
||||||
|
@ -27,6 +30,7 @@ def test():
|
||||||
#search for a file in account
|
#search for a file in account
|
||||||
file = m.find('tests.py')
|
file = m.find('tests.py')
|
||||||
|
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
#get public link
|
#get public link
|
||||||
link = m.get_link(file)
|
link = m.get_link(file)
|
||||||
|
|
Loading…
Reference in a new issue