OneList

基于Python3的简约OneDrive目录列表,同时换了一种api来防止因使用人过多导致抽风等问题,稳定性大大的增加,而且使用Redis动态缓存策略,打开目录的速度是相当的快,不过该程序初衷只想安静的做个目录程序,所以是不会增加看视频的功能。

https://github.com/0oVicero0/OneList

安装

1.安装依赖

  • CenOS 6系统

shell
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
#安装EPEL rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm #安装Python3和Redis yum install python34 redis git -y #安装pip3 wget https://bootstrap.pypa.io/get-pip.py python3 get-pip.py #启动Redis service redis start #设置Redis开机自启 chkconfig redis on
  • CenOS 7系统

shell
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12
  • 13
#安装EPEL rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm #安装Python3和Redis yum install python36 redis git -y #配置Python3软链接 ln -s /usr/bin/python3.6 /usr/bin/python3 #安装pip3 wget https://bootstrap.pypa.io/get-pip.py python3 get-pip.py #启动Redis systemctl start redis #设置Redis开机自启 systemctl enable redis

Debian/Ubuntu系统

shell
  • 01
  • 02
  • 03
#安装pip3和Redis apt update apt install python3-pip redis-server git -y

2.安装OneList

shell
  • 01
  • 02
  • 03
  • 04
#拉取源码 git clone https://github.com/0oVicero0/OneList.git #安装依赖 cd OneList && pip3 install -r requirements.txt

3.获取auth_token

使用浏览器访问该地址:单击,登录你的OneDrive账号,复制地址栏code=和&session之间的参数。

4.获取refresh_token

在SSH客户端使用命令:

shell
  • 01
  • 02
  • 03
#将下面auth_token替换成你获取到的参数,再使用命令 code="auth_token" wget –no-check-certificate –post-data="client_id=ea2b36f6-b8ad-40be-bc0f-e5e4a4a7d4fa&client_secret=h27zG8pr8BNsLU0JbBh5AOznNS5Of5Y540l/koc7048=&grant_type=authorization_code&resource=https://api.office.com/discovery/&redirect_uri=http://localhost/onedrive-login&code=$code" ‘https://login.microsoftonline.com/common/oauth2/token’ -qO-

然后复制refresh_token参数后面的字段。

5.配置OneList

在OneList目录新建config.json配置文件

nano config.json

将以下内容复制进去:注意(start_directory是选择要分享的目录)。

  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
#将下面refresh_token替换成你获取到的字段 注意不要带<> { "token": "<refresh_token>", "location_path": "/", "start_directory": "/", "threads": 3, "diff_seconds": 480, "refresh_seconds": 720, "metadata_cached_seconds": 768, "structure_cached_seconds": 840 }

再使用ctrl+x、y保存退出。

6.开始运行

gunicorn app:app -b 127.0.0.1:8888 -D

注意端口可以任意选择。此时访问地址为127.0.0.1:8888,还需要使用域名反代才能访问,如果你要使用ip访问,将运行命令改成0.0.0.0:8888即可。

7.反向代理

如果需要推荐用宝塔面板做一下反代就行

把目标URL改成http://127.0.0.1:8888就行。

8.重启

当长时间运行服务器出现错误的时候,通过下面的方式进行重启

  • 1)输入通过执行如下命令,可以获取Gunicorn进程树:pstree -ap|grep gunicorn

  • 2)重启Gunicorn任务:kill -HUP 2883

  • 3)当然了也可以关闭再启动:kill -9 2883