mega.co.nz命令行客户端。
megacl的Python项目详细描述
警告
这个工具很可能已经过时,而且目前还没有维护。
兆赫
mega.co.nz命令行客户端
安装
只需使用:
$ pip install megacl
或:
$ sudo pip install megacl
pip将处理依赖关系。注意,在所有依赖项中,megacl需要pycrypto,这不是一个纯python模块,并且不通过pypi为法律事务提供二进制文件。
有些人可能会发现单独安装pycrypto很有用,特别是在您没有安装c编译环境的情况下。
- 您可以在http://www.voidspace.org.uk/python/modules.shtml上找到windows的pycrypto。
- 你可以在python-crypto 这个名字下找到ubuntu的pycrypto。
用法
$ mcl help Usage: mcl [GLOBAL OPTIONS] COMMAND_NAME [OPTIONS] [VALUES] A command line tool for mega.co.nz Commands: find list files on mega get get one or more files geturl get from a url help give help info get informations on a file or folder login login to mega logout logout from mega ls list files in a mega directory mkdir create a new remote directory mv move an item into another directory (move,mv) put put one or more files quota get account's quota reload reload the filesystem rename rename an item show list files on mega Global options: --debug Provide some debug informations (--debug,-d) --help Get help on specific command (--help,-h) --login=VALUE The login to use when mode --no-config --no-config Don't read/write config files (--no-config,-X) --password=VALUE The password to use when mode --no-config (not safe, prefer the login command) --profile=VALUE Use a different profile than the default (--profile,-P) --reload Force reload before the first action that need the filesystem (--reload,-r)
登录
要使用此工具,您首先需要登录:
$ mcl login --email=dave@example.com Login : [dave@example.com] Password: login success
一旦你登录,而你的密码却不在任何地方存储, 您的主密钥和loggin会话的当前sid被存储 在配置文件~/.megaclient/config中。如果这是 任何问题,请不要使用此工具。
显示并查找
要显示帐户上的所有目录和文件,请使用show或find命令:
$ mcl show :ybRwIWgK 'Cloud Drive' :RTgRCjhY 'Documents' :3DBFSa9S 'mydoc.txt' :iSpGZz4J 'Test' :QKxQzDlD 'Image test.png' :DDAgCv1a 'xkcd' :TKhFSKhJ '163-donald_knuth.png' :gKJlhatb '184-matrix_transform.png' :CLRGYv5Y '303-compiling.png' :0TwEKCpb '353-python.png' :RIQXhqtZ 'Inbox' :TK5UwKlS 'Rubbish Bin' $ mcl find :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin'
您也可以使用过滤器:
$ mcl show -f ytho :0TwEKCpb '353-python.png' $ mcl find -f ytho :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' $ mcl show -f es :iSpGZz4J 'Test' :QKxQzDlD 'Image test.png' $ mcl find -f es :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png'
两个命令都支持--long/-lparamater(它提醒ls -lpresentation):
$ mcl find -l -f es durwx :iSpGZz4J 2013-02-01 15:45:01 '/Cloud Drive/Test' --rw- :QKxQzDlD 3102405 2013-02-01 18:12:47 '/Cloud Drive/Test/Image test.png' durwx :DDAgCv1a 2013-04-11 15:37:01 '/Cloud Drive/Test/xkcd' --rw- :TKhFSKhJ 32884 2006-09-27 09:51:44 '/Cloud Drive/Test/xkcd/163-donald_knuth.png' --rw- :gKJlhatb 6903 2006-11-15 07:14:22 '/Cloud Drive/Test/xkcd/184-matrix_transform.png' --rw- :CLRGYv5Y 28315 2007-08-15 12:10:02 '/Cloud Drive/Test/xkcd/303-compiling.png' --rw- :0TwEKCpb 90835 2007-12-05 09:32:48 '/Cloud Drive/Test/xkcd/353-python.png'
两个命令都支持--short/-s参数,该参数提供更适合脚本/管道的输出:
$ mcl find -s -f es /Cloud Drive/Test /Cloud Drive/Test/Image test.png /Cloud Drive/Test/xkcd /Cloud Drive/Test/xkcd/163-donald_knuth.png /Cloud Drive/Test/xkcd/184-matrix_transform.png /Cloud Drive/Test/xkcd/303-compiling.png /Cloud Drive/Test/xkcd/353-python.png
获取和放置
每个结果行的第一部分是文件句柄。当你 需要指定文件或目录,可以使用 路径或其句柄(包括“:”):
$ mcl get :0TwEKCpb Getting [353-python.png] (90835 bytes) Transfert completed in 0.1 seconds (1107.85 KiB/s) $ mcl get '/Cloud Drive/Test/xkcd/353-python.png' Getting [353-python.png] (90835 bytes) Transfert completed in 0.1 seconds (1217.35 KiB/s)
get是下载文件,也可以使用put:
$ mcl put ../docs/README.md :iSpGZz4J Sending [README.md] (548655 bytes) Transfert completed in 1.8 seconds (297.7 KiB/s)
重新加载
要重新加载文件列表,请使用reload:
$ mcl reload $ mcl find :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :4sMDajOQ '/Cloud Drive/Test/README.md' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin'
ls
您还可以使用类似unix的ls命令:
$ mcl ls '/Cloud Drive/Test' Image test.png README.md xkcd
命令ls支持--long/-l参数(例如ls -l):
$ mcl ls --help Command: ls [OPTIONS] [VALUES] list files in a mega directory Command parameters: --long use a long listing format (--long,-l)
$ mcl ls -l '/Cloud Drive/Test' --rw- :QKxQzDlD 3102405 2013-02-01 18:12:47 Image test.png --rw- :4sMDajOQ 1850 2013-04-28 12:02:21 README.md durwx :DDAgCv1a 2013-04-11 15:37:01 xkcd
mkdir
您可以使用mkdir命令创建新文件夹:
$ mcl find :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :4sMDajOQ '/Cloud Drive/Test/README.md' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin' $ mcl mkdir Subdir '/Cloud Drive/Test' $ mcl find --reload :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :4sMDajOQ '/Cloud Drive/Test/README.md' :bU7dxMP4 '/Cloud Drive/Test/Subdir' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin'
注意:bU7dxMP4 '/Cloud Drive/Test/Subdir'行的存在。
您可以指定父目录的完整路径或其句柄:
$ mcl mkdir Subdir :iSpGZz4J
移动
您可以使用move/mv命令将文件或文件夹移动到另一个文件夹:
$ mcl find :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :4sMDajOQ '/Cloud Drive/Test/README.md' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin' $ mcl move '/Cloud Drive/Test/Image test.png' '/Cloud Drive/Documents' $ mcl find --reload :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :QKxQzDlD '/Cloud Drive/Documents/Image test.png' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :4sMDajOQ '/Cloud Drive/Test/README.md' :bU7dxMP4 '/Cloud Drive/Test/Subdir' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin' $ # To move back the file using the handles $ mcl move :QKxQzDlD :iSpGZz4J
也可以使用此命令移动多个文件或文件夹:
$ mcl find :ybRwIWgK '/Cloud Drive' :RTgRCjhY '/Cloud Drive/Documents' :3DBFSa9S '/Cloud Drive/Documents/mydoc.txt' :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :4sMDajOQ '/Cloud Drive/Test/README.md' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin' $ mcl move :gKJlhatb :0TwEKCpb :CLRGYv5Y :RTgRCjhY '/Cloud Drive/Test' $ mcl find --reload :ybRwIWgK '/Cloud Drive' :iSpGZz4J '/Cloud Drive/Test' :gKJlhatb '/Cloud Drive/Test/184-matrix_transform.png' :CLRGYv5Y '/Cloud Drive/Test/303-compiling.png' :0TwEKCpb '/Cloud Drive/Test/353-python.png' :RTgRCjhY '/Cloud Drive/Test/Documents' :3DBFSa9S '/Cloud Drive/Test/Documents/mydoc.txt' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :4sMDajOQ '/Cloud Drive/Test/README.md' :bU7dxMP4 '/Cloud Drive/Test/Subdir' :DDAgCv1a '/Cloud Drive/Test/xkcd' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' :RIQXhqtZ '/Inbox' :TK5UwKlS '/Rubbish Bin'
配额
使用可以通过以下方式查看您的空间使用情况:
$ mcl quota Current quota: [21.00/50.00]
这意味着你用的是你50.00吉布中的21.00吉布。
无状态使用,不涉及配置文件
登录信息和目录缓存存储在 文件系统。您还可以将此工具与 开关--no-config(或-X)。那你必须 在每个上提供--login和--password命令 电话。注意,在命令行上提供密码 被认为是错误做法。
命令如下:
$ mcl find -f es --no-config --login=dave@example.com --password=r_N71kL4ee:cG28p-N,aam4 :iSpGZz4J '/Cloud Drive/Test' :QKxQzDlD '/Cloud Drive/Test/Image test.png' :DDAgCv1a '/Cloud Drive/Test/xkcd' :gKJlhatb '/Cloud Drive/Test/xkcd/184-matrix_transform.png' :0TwEKCpb '/Cloud Drive/Test/xkcd/353-python.png' :CLRGYv5Y '/Cloud Drive/Test/xkcd/303-compiling.png' :TKhFSKhJ '/Cloud Drive/Test/xkcd/163-donald_knuth.png' $ mcl ls -l '/Cloud Drive/Test' --no-config --login=dave@example.com --password=r_N71kL4ee:cG28p-N,aam4 --rw- :QKxQzDlD 3102405 2013-02-01 18:12:47 Image test.png --rw- :4sMDajOQ 1850 2013-04-28 12:02:21 README.md durwx :DDAgCv1a 2013-04-11 15:37:01 xkcd
剖面图
默认情况下,有些命令存储在配置文件/缓存文件中 配置目录。
如果出于某种原因,您需要在不注销的情况下使用其他配置文件 在第一个概要文件中,可以使用全局参数--profile(-P)。
假设您像往常一样登录dave@example.com,并使用 乔纳森想从他的how帐户(jonathan@example.com)下载一个文件给你看。你 然后可以简单地使用配置文件:
$ # you are logged $ mcl ls '/Cloud Drive' Documents Test $ # jonathan will login $ mcl -P jonathan login --email=jonathan@example.com Login : [jonathan@example.com] Password: login success $ mcl -P jonathan ls '/Cloud Drive' Sintel.2010.1080p.mkv sintel_en.srt sintel_es.srt sintel_fr.srt sintel_de.srt sintel_nl.srt sintel_it.srt sintel_pt.srt sintel_pl.srt sintel_ru.srt sintel_trailer-1080p.mp4 $ # Note you're still logged in as dave on default profile $ mcl ls --reload '/Cloud Drive' Documents Test $ mcl -P jonathan get '/Cloud Drive/Sintel.2010.1080p.mkv' '/Cloud Drive/sintel_it.srt' Getting [Sintel.2010.1080p.mkv] (1180090590 bytes) Transfert completed in 57.0 seconds (20218.1 KiB/s) Getting [sintel_it.srt] (1544 bytes) Transfert completed in 0.8 seconds (1.88 KiB/s) $ mcl -P jonathan logout $ mcl -P jonathan ls '/Cloud Drive' Error : You must login first $ mcl ls --reload '/Cloud Drive' Documents Test
详细帮助
在每个命令上,您都可以使用--help:
$ mcl find --help Command: [GLOBAL OPTIONS] find [OPTIONS] [VALUES] list files on mega Command options: --filter=VALUE filter the result using VALUE (--filter,-f) --long use a long listing format (--long,-l) --short use short listing format (only the path) (--short,-s) Global options: --debug Provide some debug informations (--debug,-d) --help Get help on specific command (--help,-h) --login=VALUE The login to use when mode --no-config --no-config Don't read/write config files (--no-config,-X) --password=VALUE The password to use when mode --no-config (not safe, prefer the login command) --profile=VALUE Use a different profile than the default (--profile,-P) --reload Force reload before the first action that need the filesystem (--reload,-r)
在命令help上使用此on选项时,所有命令的详细信息:
$ mcl help --help Usage: mcl [GLOBAL OPTIONS] COMMAND_NAME [OPTIONS] [VALUES] A command line tool for mega.co.nz Commands: find list files on mega get get one or more files geturl get from a url help give help info get informations on a file or folder login login to mega logout logout from mega ls list files in a mega directory mkdir create a new remote directory mv move an item into another directory (move,mv) put put one or more files quota get account's quota reload reload the filesystem rename rename an item show list files on mega Global options: --debug Provide some debug informations (--debug,-d) --help Get help on specific command (--help,-h) --login=VALUE The login to use when mode --no-config --no-config Don't read/write config files (--no-config,-X) --password=VALUE The password to use when mode --no-config (not safe, prefer the login command) --profile=VALUE Use a different profile than the default (--profile,-P) --reload Force reload before the first action that need the filesystem (--reload,-r) find options: --filter=VALUE filter the result using VALUE (--filter,-f) --long use a long listing format (--long,-l) --short use short listing format (only the path) (--short,-s) info options: --attributes show only attributes (--attr,--attributes,-a) --handle show only handle (--handle,-H) --name show only name (--name,-n) --path show only path (--path,-p) --size show only size (--size,-s) --time show only time (--time,-t) login options: --email=VALUE The login/email (--email,-e) ls options: --long use a long listing format (--long,-l) show options: --filter=VALUE filter the result using VALUE (--filter,-f) --long use a long listing format (--long,-l) --short use short listing format (only the indent and the name) (--short,-s)