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)
|
m = mega.login(email, password)
|
||||||
|
|
||||||
|
### Get user details
|
||||||
|
|
||||||
|
details = m.get_user()
|
||||||
|
|
||||||
### Get account files
|
### Get account files
|
||||||
|
|
||||||
files = m.get_files()
|
files = m.get_files()
|
||||||
|
|
8
mega.py
8
mega.py
|
@ -104,6 +104,11 @@ class Mega(object):
|
||||||
else:
|
else:
|
||||||
raise errors.RequestError('Url key missing')
|
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):
|
def download_file(self, file_id, file_key, is_public=False):
|
||||||
if is_public:
|
if is_public:
|
||||||
file_key = base64_to_a32(file_key)
|
file_key = base64_to_a32(file_key)
|
||||||
|
@ -122,6 +127,8 @@ class Mega(object):
|
||||||
attribs = decrypt_attr(attribs, k)
|
attribs = decrypt_attr(attribs, k)
|
||||||
file_name = attribs['n']
|
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
|
input_file = requests.get(file_url, stream=True).raw
|
||||||
output_file = open(file_name, 'wb')
|
output_file = open(file_name, 'wb')
|
||||||
|
|
||||||
|
@ -168,6 +175,7 @@ class Mega(object):
|
||||||
else:
|
else:
|
||||||
raise errors.ValidationError('File id and key must be set')
|
raise errors.ValidationError('File id and key must be set')
|
||||||
|
|
||||||
|
|
||||||
def upload(self, filename, dest=None):
|
def upload(self, filename, dest=None):
|
||||||
#determine storage node
|
#determine storage node
|
||||||
if dest is None:
|
if dest is None:
|
||||||
|
|
|
@ -10,6 +10,10 @@ def test():
|
||||||
#login
|
#login
|
||||||
m = mega.login(email, password)
|
m = mega.login(email, password)
|
||||||
|
|
||||||
|
#get user details
|
||||||
|
details = m.get_user()
|
||||||
|
print(details)
|
||||||
|
|
||||||
#get account files
|
#get account files
|
||||||
files = m.get_files()
|
files = m.get_files()
|
||||||
print(files)
|
print(files)
|
||||||
|
|
Loading…
Reference in a new issue