Last active
August 31, 2021 05:40
-
-
Save stefanocudini/5502087 to your computer and use it in GitHub Desktop.
script uploader for multiple files, using mega.co.nz python API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
#require: https://github.com/richardasaurus/mega.py | |
# | |
import os | |
import sys | |
from mega import Mega | |
mega = Mega({'verbose': True}) | |
m = mega.login('megauseremail', 'megapass') | |
curDir = os.getcwd() + os.path.sep | |
dstDirId = None | |
if len(sys.argv)>1 and sys.argv[1]: | |
srcs = sys.argv[1:] | |
else: | |
srcs = None | |
print srcs | |
if srcs: | |
if len(srcs) > 1 and not os.path.isfile( srcs[-1] ):#if last param isn't a local file then it is dest remote folder | |
dstName = srcs.pop() | |
dstId = m.find( dstName ) | |
if dstId: | |
dstDirId = dstId[0] | |
print 'Destination Folder: '+ dstName | |
for src in srcs: | |
srcFile = curDir + src | |
if os.path.isfile( srcFile ): | |
#print srcFile | |
#print dstDirId | |
uppedFile = m.upload(srcFile, dstDirId) | |
print uppedFile | |
print 'Upped File Link: ' + m.get_upload_link( uppedFile ) |
You have download Mega: sudo pip install mega.py
can you make a simple callin example?
Hello, how do i use it? what shall i modify?
tu peut télécharger le module mega ici : https://pypi.org/project/mega.py/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
Where can I download Mega module?