Onedrivecmd|OneDrive的命令行客户端|可直接上传|下载文件等

cera cera

说明:onedrivecmd是一个OneDrive的命令行客户端,可以直接在VPS上对OneDrive网盘进行上传/下载/编辑等操作,还可以直接将文件离线到网盘,支持OneDrive个人版和商业版等,该工具和博主以前发个2Google Drive命令行工具差不多,查看:skicka、Gdrive,对Google Drive更有兴趣的可以试试。

功能

  • 根据路径取文件。
  • 配置文件 (~/.onedrive.json)。
  • 可对单个文件上传下载。
  • 可列远程目录,包括文件大小和时间戳。
  • 上传与下载有进度条,也可用aria2进行下载。
  • 离线下载(此功能仅通过API提供,Web和官方客户端都是没有的)。
  • 直接获取直链!。
  • Python 23通用。

安装

Github地址:https://github.com/cnbeining/onedrivecmd

说明:博主使用Python 23测试了下,发现Python 2下会出现点小问题,不过也还是可以用的,这里建议通过Python 3安装Onedrivecmd

1、安装pip或pip3
如果你想用Python 2,一般系统都自带Python 2,可以使用以下命令安装pip

#CentOS 6.x 32位
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum install -y python-pip

#CentOS 6.x 64位
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install -y python-pip

#CentOS 7.x
yum install -y epel-release
yum install -y python-pip
#如果CentOS 7安装出现No package python-pip available,可以用以下命令进行安装
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

#Debian/Ubuntu系统
apt-get -y update
apt-get -y install python-pip

如果你想用Python 3,可以使用以下脚本自动安装Python 3pip3

#Ubuntu很多系统自带Python 3,就不说安装方法了
#CentOS系统
wget https://www.moerats.com/usr/shell/Python3/CentOS_Python3.6.sh && sh CentOS_Python3.6.sh
#Debian系统
wget https://www.moerats.com/usr/shell/Python3/Debian_Python3.6.sh && sh Debian_Python3.6.sh

#查看是否安装成功
python3 -V

2、安装onedrivecmd

#Python 2安装
pip install onedrivecmd

#Python 3安装
pip3 install onedrivecmd

使用

1、使用命令

#注意根目录为od:/,后面带/为目录,不带为文件
Usage onedrivecmd:
onedrivecmd -h 
onedrivecmd [OPTIONS] init 个人版登陆
onedrivecmd [OPTIONS] init_business 企业/Office 365/Education登陆
onedrivecmd [OPTIONS] list od:/foo/bar/ 列目录
onedrivecmd [OPTIONS] share od:/foo/bar/ 共享
onedrivecmd [OPTIONS] direct od:/foo/bar/ 取直链!这个直链不过期
onedrivecmd [OPTIONS] get od:/foo/file.txt /tmp/ 下载
onedrivecmd [OPTIONS] put /tmp/hello.txt od:/bar/ 上传
onedrivecmd [OPTIONS] delete od:/foo/bar 删除
onedrivecmd [OPTIONS] mkdir od:/foo/bar/ 建目录
onedrivecmd [OPTIONS] search foobar 搜索
onedrivecmd [OPTIONS] remote http://thecatapi.com/api/images/get?format=src&type=gif 离线下载
onedrivecmd [OPTIONS] quota 看容量

[OPTIONS]
-conf="~/.onedrive.json": 配置文件,此文件和密码一样重要
-h: 帮助
-hack: 用SDK上传/aria2下载
-recursive=false: 递归列目录,速度比想象中慢得多
-chunk=62914560: 上传分片大小,必须是320K的倍数,不能超过60MB
-url=False: 只列出文件下载URL,这个URL失效很快

2、使用示例
首先使用命令登录OneDrive

#个人版登录命令
onedrivecmd init

#企业/Office 365/Education登录命令
onedrivecmd init_business

然后将那串网址复制到浏览器登录账号,再将验证码输到SSH客户端确认。

注意默认配置文件是/root/.onedrive.json,可以自己设置。此文件和你的密码一样重要!泄露会导致你的盘被随便查看!

最后配置成功后,就可以使用上面的命令进行操作了。

cera cloudiplc tengxunyun

相关推荐

mjjping.com cera cera cloudiplc