How to list files of a mega.nz folder using python 3.9.1?

I only found this:

m = mega.login('email', 'password')
files = m.get_files()
extracted = []
for file in files: extracted.append(files[file]['a']['n'])

it returns all of the files and folders:

['Cloud Drive', 'Inbox', 'Rubbish Bin', 'Welcome to MEGA.pdf', 'FolderN1', 'balloon.png', 'FolderN1/subfolder/balloon.png', 'subfolder', etc. ]
2

1 Answer

if (files[x]['t'] == 0) it is file.

files = m.get_files()
extracted = []
for x in files: if files[x]['t'] == 0: extracted.append(files[x]['a']['n'])

example results:

['video.zip', 'film.mkv', 'legal_data.zip', 'tools.py', 'upload.py', 'learn.pdf']

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like