Added get_user() details
This commit is contained in:
parent
e67db04f14
commit
7333801e86
3 changed files with 16 additions and 0 deletions
|
@ -14,6 +14,10 @@ This is a work in progress, further functionality coming shortly.
|
|||
|
||||
m = mega.login(email, password)
|
||||
|
||||
### Get user details
|
||||
|
||||
details = m.get_user()
|
||||
|
||||
### Get account files
|
||||
|
||||
files = m.get_files()
|
||||
|
|
8
mega.py
8
mega.py
|
@ -104,6 +104,11 @@ class Mega(object):
|
|||
else:
|
||||
raise errors.RequestError('Url key missing')
|
||||
|
||||
def get_user(self):
|
||||
user_data = self.api_request({'a': 'ug'})
|
||||
return user_data
|
||||
|
||||
|
||||
def download_file(self, file_id, file_key, is_public=False):
|
||||
if is_public:
|
||||
file_key = base64_to_a32(file_key)
|
||||
|
@ -122,6 +127,8 @@ class Mega(object):
|
|||
attribs = decrypt_attr(attribs, k)
|
||||
file_name = attribs['n']
|
||||
|
||||
print "Downloading %s (size: %d), url = %s" % (attribs['n'], file_size, file_url)
|
||||
|
||||
input_file = requests.get(file_url, stream=True).raw
|
||||
output_file = open(file_name, 'wb')
|
||||
|
||||
|
@ -168,6 +175,7 @@ class Mega(object):
|
|||
else:
|
||||
raise errors.ValidationError('File id and key must be set')
|
||||
|
||||
|
||||
def upload(self, filename, dest=None):
|
||||
#determine storage node
|
||||
if dest is None:
|
||||
|
|
|
@ -10,6 +10,10 @@ def test():
|
|||
#login
|
||||
m = mega.login(email, password)
|
||||
|
||||
#get user details
|
||||
details = m.get_user()
|
||||
print(details)
|
||||
|
||||
#get account files
|
||||
files = m.get_files()
|
||||
print(files)
|
||||
|
|
Loading…
Reference in a new issue