阿里云盘上传脚本

Overview

阿里云盘上传脚本

如有侵权,请联系我删除

禁止用于非法用途,违者后果自负

环境要求

  • python3

使用方法

安装

git clone https://github.com/Hidove/aliyundrive-uploader.git
cd aliyundrive-uploader
pip install -r requirements.txt

如果执行pip install时提示-bash: pip: command not found 就是pip命令没有安装,执行下方命令安装即可,然后再执行即可

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
  • 重命名example.config.jsonconfig.json
  • 填写好config.json的内容

{
  "REFRESH_TOKEN": "refresh_token",
  "DRIVE_ID": "drive_id",
  "ROOT_PATH": "网盘目录",
  "FILE_PATH": "D:\\Pictures\\",
  "MULTITHREADING": false,
  "MAX_WORKERS": 5,
  "CHUNK_SIZE": 104857600
}
参数 注释
REFRESH_TOKEN 阿里云盘刷新的token
DRIVE_ID 阿里云盘驱动ID,目前不知道做何使用的,可能后续官方有新想法吧
ROOT_PATH 阿里云盘目录 我的照片
FILE_PATH 文件夹目录,填写绝对路径 D:\Pictures\
MULTITHREADING 是否启用多线程 true/false
MAX_WORKERS 线程池最大线程数,请根据自己机器填写 5
CHUNK_SIZE 分块上传大小,请根据自己机器填写,单位:字节 104857600
RESUME 断点续传,分块续传 true/false

运行

chmod +x main.py

多文件上传

python3 main.py
python3 main.py /www/wwwroot/download/

单文件上传

python3 main.py /www/lixiaoen.jpg

更新

cd ~/aliyundrive-uploader
git fetch --all 
git reset --hard origin/master 
git pull

文件解读

  • config.json
    • 脚本配置文件
  • task.json
    • 脚本上传任务记录文件
  • /log
    • 脚本执行记录

支持

觉得写得不错可以给我打赏哦

Comments
  • 上传文件时报错

    上传文件时报错

    {"code":"InvalidParameter.ContentHash","message":"The input parameter content_hash is not valid. file content hash is not matched with content_hash in complete file request"}

    opened by gifyic 12
  • 开始上传后报错

    开始上传后报错

    检索目录中 目录id获取成功60898fee4524df8614d74fa6a9df689e35b4ea0a 正在上传: 1%|1 | 53.0M/6.84G [00:30<1:06:53, 1.82MB/s] Traceback (most recent call last): File "/root/aliyundrive-uploader/main.py", line 137, in if res.result(): File "/usr/lib/python3.9/concurrent/futures/_base.py", line 438, in result return self.__get_result() File "/usr/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result raise self._exception File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/root/aliyundrive-uploader/main.py", line 61, in upload_file drive.upload(upload_url) File "/root/aliyundrive-uploader/AliyunDrive.py", line 117, in upload res.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://bj29.cn-beijing.data.alicloudccp.com/xYBXOEkb%2F69848%2F608991ae51a2863ccd5b466b8bf84ab711c83d46%2F608991ae11f21bbc22964fbbaf08e0f2fca9d24f?Expires=1619632062&OSSAccessKeyId=LTAIsE5mAn2F493Q&Signature=IUxxWsQ36QnVxA0W%2FnwWESNHsfs%3D&partNumber=1&uploadId=658982D766A74E5AB6BB7D64A564C38C

    opened by zsbai 9
  • 能加断点续传吗?

    能加断点续传吗?

    我一个1G的文件从Ubuntu 20.04服务器上传到阿里云网盘老是出错,每次都有重新开始传,错误提示:

    pipes-presentation-20210423.mp4正在校检文件中,耗时与文件大小有关 文件名:11-pipes-presentation-20210423.mp4 hash:4817bcc8425ac8be2264ff379887a64b0f46e661 文件大小:1134460273 文件路径:youtube/11-pipes-presentation-20210423.mp4

    检索目录中 目录id获取成功6073f804da645896ab184012afdfd4e0c7fe9ab3 Traceback (most recent call last): File "main.py", line 137, in if res.result(): File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result return self.__get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result raise self._exception File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "main.py", line 61, in upload_file drive.upload(upload_url) File "/root/aliyundrive-uploader/AliyunDrive.py", line 117, in upload res.raise_for_status() File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://bj29.cn-beijing.data.alicloudccp.com/4oW5G1mH%2F27564%2F6088ab6af27e6944c74c4b0aa509838b6182e85d%2F6088ab6a58520b3afd2b480a8a7b020fa7df8982?Expires=1619573114&OSSAccessKeyId=LTAIsE5mAn2F493Q&Signature=xEewGJ4QSlF1Ir8u7%2Bd0biuKyp4%3D&partNumber=1&uploadId=BD00C9F4C9CF4E2B8C71C5620236BB42

    opened by ddfiberglass 7
  • 是否可以跳过文件校检(哈希),直接上传

    是否可以跳过文件校检(哈希),直接上传

    现在上传文件前都需要检查文件哈希值,如果云端存在该文件,就会秒传。

    我会打包并加密上传的照片,因此每个文件必定是独一无二的,因此希望直接跳过哈希计算,直接上传。

    由于每次会上传数百G的文件,浪费CPU也浪费电,浪费煤炭,产生二氧化碳,污染环境。。。(喂扯远了。。)

    希望能稍微增加一个配置选项。谢谢!

    opened by lesca 5
  • 关于应用性能的建议

    关于应用性能的建议

    建议重写ACCESS_TOKEN管理服务

    • Aliyundrive当前阶段ACCESS_TOKEN约每2h刷新一次,而本项目关于ACCESS_TOKEN管理方案似乎并不科学。

    • 大概看了一下源码,本人认为本项目的ACCESS_TOKEN处于欠初始化状态。配置文件中只要求开发者(首次)手动获取DRIVE_IDREFRESH_TOKEN(然而完全可以手动初始化ACCESS_TOKEN因为它们就隔了一行,如README中的截图所示),于是程序运行后(无论ACCESS_TOKEN是否真的失效),都会在上传任务正式开始前被重新更新一次,并且在后续长段时间内子线程通过强竞争的方式进行”倒计时600s被动更新ACCESS_TOKEN“的任务。

    • 这会引发一系列难以应付的问题,check_auth()被放置在如“新建网盘目录”等多个核心业务当中。当用户配置多线程下载大量(指向目录的)小文件时,每个“分发线程”都会执行一次ACCESS_TOKEN更新请求。

    • 此外,ThreadPoolExecutor(max_workers=None, thread_name_prefix='', initializer=None, initargs=())在 3.5 版本后,如果 max_workers 为 None 或没有指定,将默认为机器处理器的个数而非1;在3.8版本后则默认启动至少5个核心线程min(32, os.cpu_count() + 4),所以我们可能消耗了成倍的资源的去”计算“更新时间,程序也会在某个时间点频繁更新权限出现“绊脚”的情况。

    建议使用 Coroutine-Pool 多路复用协程池管理任务队列

    使用通信共享内存,而不是使用内存通信。

    本项目中写满了子线程的竞争行为,这在批量传输小文件时将带来极大的性能损耗。可以使用gevent等优秀的协程框架处理密集I/O业务,在虚拟线程阻塞时让出资源,也能更加方便地管理事务回滚以及标记异常实例。

    opened by QIN2DIM 4
  • 后台运行机制代码存在bug

    后台运行机制代码存在bug

    Client.py文件中,第77行判断是否有后台运行参数时,如果存在,立刻删除会导致后面数组访问越界,原始代码如下。

    77 def init_command_line_parameter(self): 78 for k in range(len(sys.argv)): 79 if sys.argv[k] == '--resident' or sys.argv[k] == '-r': 80 DATA['config']['RESIDENT'] = True 81 del sys.argv[k]

    报错情况为: Traceback (most recent call last): File "/root/aliyundrive-uploader-master/main.py", line 26, in client.init_command_line_parameter() File "/root/aliyundrive-uploader-master/Client.py", line 77, in init_command_line_parameter if sys.argv[k] == '--resident' or sys.argv[k] == '-r': IndexError: list index out of range

    修改建议,增加标识位,for循环后再删除,如 label = -1 for k in range(len(sys.argv)): if sys.argv[k] == '--resident' or sys.argv[k] == '-r': DATA['config']['RESIDENT'] = True label = k if label>-1: del sys.argv[label]

    bug 
    opened by Nuaalzy 4
  • 上传中出现错误

    上传中出现错误

    win10 编译版本

    Traceback (most recent call last): File "main.py", line 51, in File "common.py", line 161, in print_info File "common.py", line 208, in log UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 69: illegal multibyte sequence

    [4044] Failed to execute script 'main' due to unhandled exception!

    opened by seeblog 2
  • 这种报错能否跳过,程序停下来了。

    这种报错能否跳过,程序停下来了。

    正在上传【0138 - 五一假期带孩子出去玩怎么拍美美的亲子照?.mp4】: 100MB [00:00, ?B/s] {'code': 'InvalidParameter.ContentHash', 'message': 'The input parameter content_hash is not valid. file content hash is not matched with content_hash in complete file request'}

    opened by luolovehk 2
  • Update common.py

    Update common.py

    优化大文件,添加从文件读取sha1。

    超过1T的文件,由于上传太长,上传过程中会出现上传地址失效的情况。这时如果重新上传,会再次计算sha1,然而每次计算sha1都会花费好几个小时,因此添加了这个功能。 实现比较简单,也没有考虑太多异常情况,希望作者在此基础上优化一下。这个功能对于大文件来说至关重要!感谢作者! PS: 尝试了rclone/WebDAV和其他的API后,发现这个工具是最棒的,真心感谢!

    opened by ihobin 2
  • 无法使用绝对路径上传

    无法使用绝对路径上传

    image

    单文件上传如果是传入绝对路径参数,config里的FILE_PATH为空时会出现如图的报错,文件路径变成了脚本的运行目录,如果将FILE_PATH改成文件路径就能正常上传

    所以这个FILE_PATH有什么作用吗,能否直接通过传入的路径参数修改该值?如果每次上传都要填一遍FILE_PATH岂不是很麻烦

    opened by auqhjjqdo 2
  • 建议增加日志功能

    建议增加日志功能

    首先非常感谢作者的无私分享,这个项目相当实用好用,我也非常有需求。相比Rclone机械性的上传,这个项目最大优势是支持秒传,我现在主要是利用qbittorrent下载完成后调用这个项目上传下载完的文件至阿里云盘,由于该过程均在VPS后台运行,故希望增加日志功能,便于时候查看上传的具体情况,最后再次致敬!

    opened by xiatao 1
Releases(v2.2.1)
Owner
Hidove
Hidove
A file-based quote bot written in Python

Let's Write a Python Quote Bot! This repository will get you started with building a quote bot in Python. It's meant to be used along with the Learnin

0 Jan 20, 2022
Creating a Python API, for the MakeMyTrip Flight Schedules.

MakeMyTripAPI Creating a Python API, for the MakeMyTrip Flight Schedules. Source: MakeMyTrip is an Indian online travel company founded in 2000. Headq

Aman Priyanshu 0 Jan 12, 2022
A Python API to retrieve and read MLB GameDay data

mlbgame mlbgame is a Python API to retrieve and read MLB GameDay data. mlbgame works with real time data, getting information as games are being playe

Zach Panzarino 493 Dec 13, 2022
Dados Públicos de CNPJ disponibilizados pela Receita Federal do Brasil

Dados Públicos CNPJ Fonte oficial da Receita Federal do Brasil, aqui. Layout dos arquivos, aqui. A Receita Federal do Brasil disponibiliza bases com o

Aphonso Henrique do Amaral Rafael 102 Dec 28, 2022
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% API coverage Most of the codebase is documented

7 Dec 11, 2022
Network simulation tools

Overview I'm building my network simulation environments with Vagrant using libvirt plugin on a Ubuntu 20.04 system... and I always hated how boring i

Ivan Pepelnjak 219 Jan 07, 2023
Auto-updater for the Northstar Titanfall 2 client

northstar-updater Auto-updater for the Northstar Titanfall 2 client Usage Put the exe into your Titanfall 2 directory next to Titanfall2.exe Then, whe

7 Nov 25, 2022
Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.

Twitter Nuke Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the puny and pointl

Mayur Bhoi 73 Dec 12, 2022
A stack-based systems language that supports structures, functions, expressions, and user-defined operator behaviour

A stack-based systems language that supports structures, functions, expressions, and user-defined operator behaviour. Currently compiles to URCL with plans to add additional formats in the future.

Lucida Dragon 3 Nov 03, 2022
Balsam Python client API & SDK

balsam No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) This Python package is automatically

Darren Govoni 1 Oct 22, 2021
Secret messaging app which you can use to communicate with your friends by encrypting / decrypting secret messages or sending secret message through mail.

Secret-Whisper A Secret messaging app which you can use to communicate with your friends by encrypting / decrypting secret messages 🤫 or sending secr

3 Jan 01, 2022
AUDD IS MUSIC RECOGNITION API

AUDD IS MUSIC RECOGNITION API

Abdimk 1 Dec 15, 2021
Auto-Rollnumber-sender - Auto Rollnumber sender with python

Auto-Rollnumber-sender The above code fits better on my system but it can vary s

Riya Tripathi 2 Feb 14, 2022
Cloud-native, data onboarding architecture for the Google Cloud Public Datasets program

Public Datasets Pipelines Cloud-native, data pipeline architecture for onboarding datasets to the Google Cloud Public Datasets Program. Overview Requi

Google Cloud Platform 109 Dec 30, 2022
Match-making API for OpenSanctions

OpenSanctions Match-making API This directory contains code and a Docker image for running an API to match data against OpenSanctions. It is intended

OpenSanctions.org 26 Dec 15, 2022
PancakeTrade - Limit orders and more for PancakeSwap on Binance Smart Chain

PancakeTrade helps you create limit orders and more for your BEP-20 tokens that swap against BNB on PancakeSwap. The bot is controlled by Telegram so you can interact from anywhere.

Valentin Bersier 187 Dec 20, 2022
This is a repository for the Duke University Cloud Computing course project on Serveless Data Engineering Pipeline. For this project, I recreated the below pipeline.

AWS Data Engineering Pipeline This is a repository for the Duke University Cloud Computing course project on Serverless Data Engineering Pipeline. For

15 Jul 28, 2021
Compulsory join Telegram Bot

mussjoin About Compulsory join Telegram Bot this Telegram Bot Application can be added users to Telegram Channel or Group compulsorily. in addition wh

Hamed Mohammadvand 4 Dec 03, 2021
Telegram Group Manager Bot Written In Python Using Pyrogram.

──「𝐂𝐡𝐢𝐤𝐚 𝐅𝐮𝐣𝐢𝐰𝐚𝐫𝐚」── Telegram Group Manager Bot Written In Python Using Pyrogram. Deploy To Heroku NOTE: I'm making this note to whoever

Wahyusaputra 3 Feb 12, 2022
Discord bot for calculating basic operations and formulas. (Early Development)

MathBot Discord bot for calculating basic operations and formulas. (Early Development) Commits Feel free to contribute to this bot by forking and pull

4 Jul 14, 2022