阿里云盘上传脚本

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
API RestFull de uma clinica, onde vai efetuar os agendamentos dos pacientes e mostrar o historicos de cada agendamentos

API REstFull O que tem na API Usado para clinicas. Cadastro de pacientes. Agendamentos de pacientes. Históricos dos agendamentos vinculados com a tabe

Lucas Silva 3 Aug 29, 2022
Boilerplate template for the discord-py-interactions library

discord-py-interactions_boilerplate Boilerplate template for the discord-py-interactions library Currently, this boilerplate supports discord-py-inter

Ventus 7 Dec 03, 2022
Typed interactions with the GitHub API v3

PyGitHub PyGitHub is a Python library to access the GitHub API v3 and Github Enterprise API v3. This library enables you to manage GitHub resources su

5.7k Jan 06, 2023
A Python Script to automate searching of available vaccination centers in the city and hence booking

Cowin Vaccine Availability Notifier Cowin Vaccine Availability Notifier takes your City or PIN code as an input and automatically notifies you via ema

Jayesh Padhiar 7 Sep 05, 2021
A tool written in Python used to instalock agents in VALORANT using the local API.

Valorant Instalock Tool v2.1.0 by Mr. SOSA A tool written in Python used to instalock agents in VALORANT using the local API. This is NOT a hotkey pro

Mr. SOSA 3 Nov 18, 2021
A basic Ubisoft API wrapper created in python.

UbisoftAPI A basic Ubisoft API wrapper created in python. I will be updating this with more endpoints as time goes on. Please note that this is my fir

Ethan 2 Oct 31, 2021
NewpaperNews-API - Json data of the news with python

NewsAPI API Documentation BASE_URL = "https://saurav.tech/NewsAPI/" top_headline

Aryaman Prakash 2 Sep 23, 2022
Program that uses Python to monitor grade updates in the Genesis Platform

Genesis-Grade-Monitor Program that uses Python to monitor grade updates in the Genesis Platform Guide: Install by either cloning the repo or downloadi

Steven Gatanas 1 Feb 12, 2022
AUDD IS MUSIC RECOGNITION API

AUDD IS MUSIC RECOGNITION API

Abdimk 1 Dec 15, 2021
Mini Tool to lovers of debe from eksisozluk (one of the most famous website -reffered as collaborative dictionary like reddit- in Turkey) for pushing debe (Most Liked Entries of Yesterday) to kindle every day via Github Actions.

debe to kindle Mini Tool to lovers of debe from eksisozluk (one of the most famous website -refered as collaborative dictionary like reddit- in Turkey

11 Oct 11, 2022
MCNameBot is a fast discord bot that is used to check the availability of a Minecraft name with a simple command.

MCNameBot MCNameBot is a fast discord bot that is used to check the availability of a Minecraft name with a simple command. If you would like to just

Killin 2 Oct 11, 2022
A way to export your saved reddit posts to a Notion table.

reddit-saved-to-notion A way to export your saved reddit posts and comments to a Notion table.Uses notion-sdk-py and praw for interacting with Notion

19 Sep 12, 2022
DaProfiler vous permet d'automatiser vos recherches sur des particuliers basés en France uniquement et d'afficher vos résultats sous forme d'arbre.

A but educatif seulement. DaProfiler DaProfiler vous permet de créer un profil sur votre target basé en France uniquement. La particularité de ce prog

Dalunacrobate 73 Dec 21, 2022
Replace sequence_IDs in gff3 based on given genome.fasta

gff-rename Replace the sequence IDs in a gff3 file with a set of provided sequence IDs from a genom.fasta. This is useful when a gff3 file is retrieve

tolkit 1 Nov 12, 2021
A Telegram Bot which notifies the user when a vaccine is available on CoWin Platform.

Cowin Vaccine Availability Notifier Telegram Bot A bot that notifies the available vaccines at given district in realtime. Introduction • Requirements

Arham Shah 7 Jul 31, 2021
Linkvertise-Bypass - Bypass Linkvertise advertisement

Linkvertise-Bypass Bypass Linkvertise advertisement 📕 instructions Copy And Pas

Flex Tools 4 Jun 10, 2022
Bulk convert image types with Python

Bulk Image Converter 🔥 Helper script to convert a folder's worth of images from one filetype to another, and optionally delete originals Use Setup /

1 Nov 13, 2021
Telegram bot with various Sticker Tools

Sticker Tools Bot @Sticker_Tools_Bot A star ⭐ from you means a lot to us! Telegram bot with various Sticker Tools Usage Deploy to Heroku Tap on above

Stark Bots 20 Dec 08, 2022
An alternative launcher for Lunar Client which is aimed at portability and functionality.

Portaluna An alternative launcher for Lunar Client which is aimed at portability and functionality. Features Portable. Lightweight. Functional. Note:

4 Mar 05, 2022
Threat Intel Platform for T-POTs

T-Pot 20.06 runs on Debian (Stable), is based heavily on docker, docker-compose

Deutsche Telekom Security GmbH 4.3k Jan 07, 2023